Sdk: Warnings/Errors from compile return paths relative to the project file.

Created on 7 Feb 2017  路  10Comments  路  Source: dotnet/sdk

from @fearthecowboy at https://github.com/dotnet/cli/issues/5604

Steps to reproduce

I have a solution with many projects.

If I build the .sln file from the cmdline:

dotnet build ./autorest.sln 

dotnet build .\AutoRest.sln
Microsoft (R) Build Engine version 15.1.545.13942
Copyright (C) Microsoft Corporation. All rights reserved.

  AutoRest.Core -> C:\work\github\autorest-coreclr\src\core\AutoRest.Core\bin\Debug\netstandard1.3\AutoRest.Core.dll
  AutoRest.Tooling.CSharp.Compiler -> C:\work\github\autorest-coreclr\src\dev\AutoRest.Tooling.CSharp.Compiler\bin\Debug\netstandard1.3\AutoRest.Tooling.CSharp.Compiler.dll
  AutoRest.Swagger -> C:\work\github\autorest-coreclr\src\modeler\AutoRest.Swagger\bin\Debug\netstandard1.3\AutoRest.Swagger.dll
  AutoRest.AzureResourceSchema -> C:\work\github\autorest-coreclr\src\generator\AutoRest.AzureResourceSchema\bin\Debug\netstandard1.3\AutoRest.AzureResourceSchema.dll
  AutoRest.Core.Tests -> C:\work\github\autorest-coreclr\src\core\AutoRest.Core.Tests\bin\Debug\netcoreapp1.0\AutoRest.Core.Tests.dll
  AutoRest.Extensions -> C:\work\github\autorest-coreclr\src\core\AutoRest.Extensions\bin\Debug\netstandard1.3\AutoRest.Extensions.dll
  AutoRest.Extensions.Azure -> C:\work\github\autorest-coreclr\src\core\AutoRest.Extensions.Azure\bin\Debug\netstandard1.3\AutoRest.Extensions.Azure.dll
  AutoRest.Python -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Python\bin\Debug\netstandard1.3\AutoRest.Python.dll
  AutoRest.CompositeSwagger -> C:\work\github\autorest-coreclr\src\modeler\AutoRest.CompositeSwagger\bin\Debug\netstandard1.3\AutoRest.CompositeSwagger.dll
TransformerPya.cs(82,17): warning CS0219: The variable 'ignoreNextLink' is assigned but its value is never used [C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]
TransformerPya.cs(92,17): warning CS0219: The variable 'findNextLink' is assigned but its value is never used [C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]
  AutoRest.Python.Azure -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\bin\Debug\netstandard1.3\AutoRest.Python.Azure.dll
  AutoRest.Swagger.Tests -> C:\work\github\autorest-coreclr\src\modeler\AutoRest.Swagger.Tests\bin\Debug\netcoreapp1.0\AutoRest.Swagger.Tests.dll
  AutoRest.Ruby -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Ruby\bin\Debug\netstandard1.3\AutoRest.Ruby.dll
  AutoRest.Java -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Java\bin\Debug\netstandard1.3\AutoRest.Java.dll
  AutoRest.CSharp -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp\bin\Debug\netstandard1.3\AutoRest.CSharp.dll
  AutoRest.Go -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Go\bin\Debug\netstandard1.3\AutoRest.Go.dll
  AutoRest.NodeJS -> C:\work\github\autorest-coreclr\src\generator\AutoRest.NodeJS\bin\Debug\netstandard1.3\AutoRest.NodeJS.dll
  AutoRest.Ruby.Azure -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Ruby.Azure\bin\Debug\netstandard1.3\AutoRest.Ruby.Azure.dll
  AutoRest.Java.Azure -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Java.Azure\bin\Debug\netstandard1.3\AutoRest.Java.Azure.dll
  AutoRest.Extensions.Azure.Tests -> C:\work\github\autorest-coreclr\src\core\AutoRest.Extensions.Azure.Tests\bin\Debug\netcoreapp1.0\AutoRest.Extensions.Azure.Tests.dll
  AutoRest.CompositeSwagger.Tests -> C:\work\github\autorest-coreclr\src\modeler\AutoRest.CompositeSwagger.Tests\bin\Debug\netcoreapp1.0\AutoRest.CompositeSwagger.Tests.dll
  AutoRest.Java.Azure.Fluent -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Java.Azure.Fluent\bin\Debug\netstandard1.3\AutoRest.Java.Azure.Fluent.dll
  AutoRest.Extensions.Tests -> C:\work\github\autorest-coreclr\src\core\AutoRest.Extensions.Tests\bin\Debug\netcoreapp1.0\AutoRest.Extensions.Tests.dll
  AutoRest.CSharp.Azure -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Azure\bin\Debug\netstandard1.3\AutoRest.CSharp.Azure.dll
  AutoRest.CSharp.Azure.Fluent -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Azure.Fluent\bin\Debug\netstandard1.3\AutoRest.CSharp.Azure.Fluent.dll
  AutoRest.CSharp.Unit.Tests -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Unit.Tests\bin\Debug\net461\AutoRest.CSharp.Unit.Tests.exe
  AutoRest.CSharp.Tests -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Tests\bin\Debug\netcoreapp1.0\AutoRest.CSharp.Tests.dll
  AutoRest.NodeJS.Azure -> C:\work\github\autorest-coreclr\src\generator\AutoRest.NodeJS.Azure\bin\Debug\netstandard1.3\AutoRest.NodeJS.Azure.dll
  AutoRest.CSharp.Azure.Tests -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Azure.Tests\bin\Debug\netcoreapp1.0\AutoRest.CSharp.Azure.Tests.dll
  AutoRest.CSharp.Azure.Fluent.Tests -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Azure.Fluent.Tests\bin\Debug\netcoreapp1.0\AutoRest.CSharp.Azure.Fluent.Tests.dll
  AutoRest -> C:\work\github\autorest-coreclr\src\core\AutoRest\bin\Debug\netcoreapp1.0\AutoRest.dll
  AutoRest.AzureResourceSchema.Tests -> C:\work\github\autorest-coreclr\src\generator\AutoRest.AzureResourceSchema.Tests\bin\Debug\netcoreapp1.0\AutoRest.AzureResourceSchema.Tests.dll

TransformerPya.cs(82,17): warning CS0219: The variable 'ignoreNextLink' is assigned but its value is never used [C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]
TransformerPya.cs(92,17): warning CS0219: The variable 'findNextLink' is assigned but its value is never used [C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]
    2 Warning(s)
    0 Error(s)

The errors/warnings are printed to the console with their 'project-local' path .

I can't click on the errors in VSCode, because they don't have the full path (or the path relative to the .sln folder)

# RIGHT HERE VVVV
TransformerPya.cs(82,17): warning CS0219: The variable 'ignoreNextLink' is assigned but its value is never used [C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]
TransformerPya.cs(92,17): warning CS0219: The variable 'findNextLink' is assigned but its value is never used [C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]

These lines should give be include the full path:

 .\src\generator\AutoRest.Python.Azure\TransformerPya.cs(82,17): warning CS0219: The variable 'ignoreNextLink' is assigned but its value is never used [C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]
 .\src\generator\AutoRest.Python.Azure\TransformerPya.cs(92,17): warning CS0219: The variable 'findNextLink' is assigned but its value is never used [C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]

Environment data

C:\work\github\autorest-coreclr [coreclr +0 ~2 -0 !]PS>dotnet --info
.NET Command Line Tools (1.0.0-rc4-004769)

Product Information:
 Version:            1.0.0-rc4-004769
 Commit SHA-1 hash:  9cf4e9d1d0

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15021
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.0-rc4-004769

Most helpful comment

I'm able to add '/clp:NoSummary' to the gulp command that's calling dotnet build and it's doing the right thing. 馃憤

I've also added <GenerateFullPaths>true</GenerateFullPaths> to our commonly Imported project, and that fixed the filename issues.

We're good to go!

All 10 comments

It took me a second to find the Expected v. Actual behavior, so thought I'd share.

Expected

Source file paths are shown relative to the PWD in which build was started

 .\src\generator\AutoRest.Python.Azure\TransformerPya.cs(82,17): warning CS0219: The variable 'ignoreNextLink' is assigned but its value is never used [C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]

Actual

Source file paths are shown relative to the directory containing the project, making the navigation to a source file a two-step process [look at the fully qualified project path, then figure out the relative path to the soruce file]

TransformerPya.cs(82,17): warning CS0219: The variable 'ignoreNextLink' is assigned but its value is never used [C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]

This has been standard msbuild/csc behavior for a long time.

Here's a test with bits from Visual Studio 2015 and a .NET Framework console app project:

C:\src\Solution>msbuild /v:m
Microsoft (R) Build Engine version 14.0.25420.1
Copyright (C) Microsoft Corporation. All rights reserved.

Program.cs(15,2): error CS1513: } expected [C:\src\Solution\Project\Project.csproj]

There is a GenerateFullPaths option on the Csc task corresponding to csc /fullpaths argument and so dotnet build /p:GenerateFullPaths=true will do what @fearthecowboy wants.

+@DustinCampbell re: not being able to double click in VS Code.

I was hoping there was a flag... I'm kinda curious why that's not a default, given that it's necessary to identify the file when building an .sln with more than one project file. What tools are y'all actually using to write code?

While I'm here, is there a way to only get the errors written to the console just once?

It's printing them twice, once during the build, and once at the end.

  AutoRest.Core -> C:\work\github\autorest-coreclr\src\core\AutoRest.Core\bin\Debug\netstandard1.3\AutoRest.Core.dll
  AutoRest.Swagger -> C:\work\github\autorest-coreclr\src\modeler\AutoRest.Swagger\bin\Debug\netstandard1.3\AutoRest.Swagger.dll
  AutoRest.Extensions -> C:\work\github\autorest-coreclr\src\core\AutoRest.Extensions\bin\Debug\netstandard1.3\AutoRest.Extensions.dll
  AutoRest.Extensions.Azure -> C:\work\github\autorest-coreclr\src\core\AutoRest.Extensions.Azure\bin\Debug\netstandard1.3\AutoRest.Extensions.Azure.dll
  AutoRest.Tooling.CSharp.Compiler -> C:\work\github\autorest-coreclr\src\dev\AutoRest.Tooling.CSharp.Compiler\bin\Debug\netstandard1.3\AutoRest.Tooling.CSharp.Compiler.dll
  AutoRest.AzureResourceSchema -> C:\work\github\autorest-coreclr\src\generator\AutoRest.AzureResourceSchema\bin\Debug\netstandard1.3\AutoRest.AzureResourceSchema.dll
  AutoRest.CSharp -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp\bin\Debug\netstandard1.3\AutoRest.CSharp.dll
  AutoRest.CSharp.Azure -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Azure\bin\Debug\netstandard1.3\AutoRest.CSharp.Azure.dll
  AutoRest.CSharp.Azure.Fluent -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Azure.Fluent\bin\Debug\netstandard1.3\AutoRest.CSharp.Azure.Fluent.dll
  AutoRest.Go -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Go\bin\Debug\netstandard1.3\AutoRest.Go.dll
  AutoRest.Java -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Java\bin\Debug\netstandard1.3\AutoRest.Java.dll
  AutoRest.Java.Azure -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Java.Azure\bin\Debug\netstandard1.3\AutoRest.Java.Azure.dll
  AutoRest.Java.Azure.Fluent -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Java.Azure.Fluent\bin\Debug\netstandard1.3\AutoRest.Java.Azure.Fluent.dll
  AutoRest.NodeJS -> C:\work\github\autorest-coreclr\src\generator\AutoRest.NodeJS\bin\Debug\netstandard1.3\AutoRest.NodeJS.dll
  AutoRest.NodeJS.Azure -> C:\work\github\autorest-coreclr\src\generator\AutoRest.NodeJS.Azure\bin\Debug\netstandard1.3\AutoRest.NodeJS.Azure.dll
  AutoRest.Python -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Python\bin\Debug\netstandard1.3\AutoRest.Python.dll
C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\TransformerPya.cs(82,17): warning CS0219: The variable 'ignoreNextLink' is assigned but its value is never used
[C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]
C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\TransformerPya.cs(92,17): warning CS0219: The variable 'findNextLink' is assigned but its value is never used [C
:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]
  AutoRest.Python.Azure -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\bin\Debug\netstandard1.3\AutoRest.Python.Azure.dll
  AutoRest.Ruby -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Ruby\bin\Debug\netstandard1.3\AutoRest.Ruby.dll
  AutoRest.Ruby.Azure -> C:\work\github\autorest-coreclr\src\generator\AutoRest.Ruby.Azure\bin\Debug\netstandard1.3\AutoRest.Ruby.Azure.dll
  AutoRest.CompositeSwagger -> C:\work\github\autorest-coreclr\src\modeler\AutoRest.CompositeSwagger\bin\Debug\netstandard1.3\AutoRest.CompositeSwagger.dll
  AutoRest -> C:\work\github\autorest-coreclr\src\core\AutoRest\bin\Debug\netcoreapp1.0\AutoRest.dll
  AutoRest.Core.Tests -> C:\work\github\autorest-coreclr\src\core\AutoRest.Core.Tests\bin\Debug\netcoreapp1.0\AutoRest.Core.Tests.dll
  AutoRest.Extensions.Azure.Tests -> C:\work\github\autorest-coreclr\src\core\AutoRest.Extensions.Azure.Tests\bin\Debug\netcoreapp1.0\AutoRest.Extensions.Azure.Tests.dll
  AutoRest.Extensions.Tests -> C:\work\github\autorest-coreclr\src\core\AutoRest.Extensions.Tests\bin\Debug\netcoreapp1.0\AutoRest.Extensions.Tests.dll
  AutoRest.Swagger.Tests -> C:\work\github\autorest-coreclr\src\modeler\AutoRest.Swagger.Tests\bin\Debug\netcoreapp1.0\AutoRest.Swagger.Tests.dll
  AutoRest.AzureResourceSchema.Tests -> C:\work\github\autorest-coreclr\src\generator\AutoRest.AzureResourceSchema.Tests\bin\Debug\netcoreapp1.0\AutoRest.AzureResourceSchema.Tests.
dll
  AutoRest.CompositeSwagger.Tests -> C:\work\github\autorest-coreclr\src\modeler\AutoRest.CompositeSwagger.Tests\bin\Debug\netcoreapp1.0\AutoRest.CompositeSwagger.Tests.dll
  AutoRest.CSharp.Tests -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Tests\bin\Debug\netcoreapp1.0\AutoRest.CSharp.Tests.dll
  AutoRest.CSharp.Azure.Fluent.Tests -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Azure.Fluent.Tests\bin\Debug\netcoreapp1.0\AutoRest.CSharp.Azure.Fluent.Tests.
dll
  AutoRest.CSharp.Azure.Tests -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Azure.Tests\bin\Debug\netcoreapp1.0\AutoRest.CSharp.Azure.Tests.dll
  AutoRest.CSharp.Unit.Tests -> C:\work\github\autorest-coreclr\src\generator\AutoRest.CSharp.Unit.Tests\bin\Debug\net461\AutoRest.CSharp.Unit.Tests.exe

Build succeeded.

C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\TransformerPya.cs(82,17): warning CS0219: The variable 'ignoreNextLink' is assigned but its value is never used
[C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]
C:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\TransformerPya.cs(92,17): warning CS0219: The variable 'findNextLink' is assigned but its value is never used [C
:\work\github\autorest-coreclr\src\generator\AutoRest.Python.Azure\AutoRest.Python.Azure.csproj]
    2 Warning(s)
    0 Error(s)

Time Elapsed 00:01:40.80

Which causes duplicates in VScode :
image

The warnings are showing twice because the CLI passes /clp:Summary to msbuild:

/consoleloggerparameters:<parameters>
                     Parameters to console logger. (Short form: /clp)
                     The available parameters are:
                        [...]
                        Summary--Show error and warning summary at the end. 
                        [...]

I thought dotnet build /clp:NoSummary would override it, but it does not because the CLI passes the /clp after the user arguments. (@livarcocc, I filed dotnet/cli#5607 for that.)

As a workaround, you can use raw dotnet msbuild to gain full control of the msbuild arguments:

dotnet msbuild /m /v:m /p:GenerateFullPaths=true

Closing as it is by design that the SDK has no opinion or impact on how compilation errors are formatted. That is up to whoever is launching msbuild.

I've filed linked bugs in CLI and omnisharp-vscode to improve the default experience.

I'm able to add '/clp:NoSummary' to the gulp command that's calling dotnet build and it's doing the right thing. 馃憤

I've also added <GenerateFullPaths>true</GenerateFullPaths> to our commonly Imported project, and that fixed the filename issues.

We're good to go!

Ah! It works if you pass the csproj. I think it was considering my /clp:NoSummary as the project arg to go before the rest.

yeah, the default behavior is broken. if you have multiple projects containing different files with the same names, then double-clicking on an error in one file will invariably open the _wrong_ file and navigate to whatever line number in that file leaving the user completely confused - 'there's no such error here!'

the default should always be full paths.

if you have multiple projects containing different files with the same names, then double-clicking on an error in one file will invariably open the _wrong_ file

This happens in Visual Studio too!

Was this page helpful?
0 / 5 - 0 ratings