This file has bugs in these lines:
In these two locations, there is an extra space in $(EnableNETAnalyzers ) before the closing parenthesis, causing MSBuild to not find that property:
|
<EnableNETAnalyzers Condition="'$(EnableNETAnalyzers )' == '' And |
|
<EnableNETAnalyzers Condition="'$(EnableNETAnalyzers )' == ''">false</EnableNETAnalyzers> |
So even if I set EnableNETAnalyzers to true in my csproj, it gets overriden to false because this line overrides it:
|
<EnableNETAnalyzers Condition="'$(EnableNETAnalyzers )' == ''">false</EnableNETAnalyzers> |
Once that spaces get removed, the DLLs are not found because their paths are relative to the project, not to the SDK:
|
Include="..\analyzers\Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers.dll" |
|
Include="..\analyzers\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll" |
|
Include="..\analyzers\Microsoft.CodeAnalysis.NetAnalyzers.dll" |
Error:
CSC : error CS0006: Metadata file '..\analyzers\Microsoft.CodeAnalysis.CSharp.NetAnalyzers.dll' could not be found [D:\testing\ConsoleCore\ConsoleCore.csproj]
CSC : error CS0006: Metadata file '..\analyzers\Microsoft.CodeAnalysis.NetAnalyzers.dll' could not be found [D:\testing\ConsoleCore\ConsoleCore.csproj]
So the fix is to prefix the 3 DLL paths with $(MSBuildThisFileDirectory) like this:
Include="$(MSBuildThisFileDirectory)..\analyzers\Microsoft.CodeAnalysis.VisualBasic.NetAnalyzers.dll"
Once fixed, it can find instances of the new Roslyn analyzers.
This bug is present in master and in Preview8.
cc @jmarolf @mavasani
This file has bugs in these lines:
In these two locations, there is an extra space in
$(EnableNETAnalyzers )before the closing parenthesis, causing MSBuild to not find that property:sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets
Line 22 in 4edb1eb
sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets
Line 26 in 4edb1eb
So even if I set
EnableNETAnalyzersto true in my csproj, it gets overriden tofalsebecause this line overrides it:sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets
Line 26 in 4edb1eb
Once that spaces get removed, the DLLs are not found because their paths are relative to the project, not to the SDK:
sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets
Line 37 in 4edb1eb
sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets
Line 41 in 4edb1eb
sdk/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.Sdk.Analyzers.targets
Line 44 in 4edb1eb
Error:
So the fix is to prefix the 3 DLL paths with
$(MSBuildThisFileDirectory)like this:Once fixed, it can find instances of the new Roslyn analyzers.
This bug is present in master and in Preview8.
cc @jmarolf @mavasani