Closed jcouv closed 4 years ago
Looking at the binlog from https://github.com/dotnet/roslyn/pull/32473#issuecomment-455054522, I see:
...
06:50:39.162 40:24>Project "D:\Temp\breuerTobiasRoslyn\roslyn\src\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj" (40:24) is building "D:\Temp\breuerTobiasRoslyn\roslyn\src\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf_atgkoygu_wpftmp.csproj" (162) on node 3 (_CompileTemporaryAssembly target(s)).
...
06:52:32.729 162>Target "CoreCompile: (TargetId:184)" in file "D:\Temp\breuerTobiasRoslyn\roslyn\artifacts\Bootstrap\tools\Microsoft.CSharp.Core.targets" from project "D:\Temp\breuerTobiasRoslyn\roslyn\src\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf_atgkoygu_wpftmp.csproj" (target "_CompileTemporaryAssembly" depends on it):
Building target "CoreCompile" completely.
Output file "D:\Temp\breuerTobiasRoslyn\roslyn\artifacts\obj\Microsoft.CodeAnalysis.EditorFeatures.Wpf\Debug\net472\Microsoft.CodeAnalysis.EditorFeatures.Wpf.xml" does not exist.
Set Property: NoWarn=;1701;1702;1705;1591;NU5125;1573;1591;1701;1701;1702
Using "Csc" task from assembly "C:\Users\breuer_to\.nuget\packages\microsoft.net.compilers\2.9.0-beta7-63018-03\build\..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll".
...
06:52:32.743 162>D:\Temp\breuerTobiasRoslyn\roslyn\artifacts\Bootstrap\tools\Microsoft.CSharp.Core.targets(68,10): error MSB4064: The "DisableSdkPath" parameter is not supported by the "Csc" task. Verify the parameter exists on the task, and it is a settable public instance property. [D:\Temp\breuerTobiasRoslyn\roslyn\src\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf_atgkoygu_wpftmp.csproj]
06:52:32.745 162>D:\Temp\breuerTobiasRoslyn\roslyn\artifacts\Bootstrap\tools\Microsoft.CSharp.Core.targets(52,5): error MSB4063: The "Csc" task could not be initialized with its input parameters. [D:\Temp\breuerTobiasRoslyn\roslyn\src\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf_atgkoygu_wpftmp.csproj]
Done executing task "Csc" -- FAILED. (TaskId:155)
Whereas all the others are
Using "Csc" task from assembly "D:\Temp\breuerTobiasRoslyn\roslyn\artifacts\Bootstrap\build\..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll".
Looks like the targets override for bootstrap is working (the task is called with the new argument) but the UsingTask override from the NuGet package has somehow won over the override from the bootstrap stuff.
microsoft.dotnet.arcade.sdk\1.0.0-beta.19064.4\tools\Settings.props
imports NuGet properties:
<!--
Import NuGet props to WPF temp projects (workaround for https://github.com/dotnet/sourcelink/issues/91)
-->
<Import Project="$(_WpfTempProjectNuGetFilePathNoExt).props" Condition="'$(_WpfTempProjectNuGetFilePathNoExt)' != '' and Exists('$(_WpfTempProjectNuGetFilePathNoExt).props')"/>
Roslyn's Settings.props sets a UsingTask
for ValidateBootstrap
in the same task assembly, but defers to
the bootstrap package to do the Csc
task
https://github.com/dotnet/roslyn/blob/fc965b58756e08aa99e238cbf2e60afbfbedcae4/eng/targets/Settings.props#L130-L134
That comes after the NuGet import, so it should override
And the .props has nice, straightforward file references that shouldn't be subject to delayed property override:
So that all seems ok. Which isn't what I was expecting! Not sure what the problem is.
I think I'm getting closer and would like to share my current progress...
After debugging MSBuild (current master of MSBuild) for a little while and getting my head around what is going on in there, I'm currently looking at TaskRegistry
especially at GetRelevantRegistrations
and GetMatchingRegistration
.
In GetMatchingRegistration
there are cases (meaning 155 times) where there are multiple (meaning exactly 2) candidates given in the taskRecords List for the tasks
Out of those 155 times where this happens, in 7 cases, the order of the candidates is "wrong" - where "wrong" in this case means, that the order is (The values show the Property RegisteredTaskRecord.TaskFactoryAssemblyLoadInfo.AssemblyLocation
):
[0] "C:\Users\breuer_to\.nuget\packages\microsoft.net.compilers\2.9.0-beta7-63018-03\build\..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll"
[1] "D:\Temp\breuerTobiasRoslyn\roslyn\artifacts\Bootstrap\build\..\tools\Microsoft.Build.Tasks.CodeAnalysis.dll"
In all other cases, the order is the other way round. These 7 cases are given when building the targets for the following projects:
- src\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf_40112gsj_wpftmp.csproj
- src\VisualStudio\Core\Def\Microsoft.VisualStudio.LanguageServices_gztxr0cb_wpftmp.csproj
- src\VisualStudio\Core\Impl\Microsoft.VisualStudio.LanguageServices.Implementation_tvlqxaba_wpftmp.csproj
- src\VisualStudio\CSharp\Impl\Microsoft.VisualStudio.LanguageServices.CSharp_d2powiwz_wpftmp.csproj
- src\VisualStudio\VisualBasic\Impl\Microsoft.VisualStudio.LanguageServices.VisualBasic_gn1xndku_wpftmp.vbproj
- src\Test\Diagnostics\Roslyn.Hosting.Diagnostics_yevfvqi1_wpftmp.csproj
- src\VisualStudio\VisualStudioDiagnosticsToolWindow\Roslyn.VisualStudio.DiagnosticsWindow_13ktqd1u_wpftmp.csproj
And there are exactly 7 of such projects that have a wpftmp suffix. So for every of these temporary projects created during the build, the order of "task factory candidates" is "wrong".
As GetMatchingRegistration
returns the first record
for which CanTaskBeCreatedByFactory
returns true, the build will fail for those 7 temporary projects.
The question is now of course
I'm going to look further into this and see if I can narrow it down further - but I'm in no way an MSBuild expert - so if you @rainersigwald have any idea on where to look next please let me know 😉.
As I'm not an expert, please don't shoot me for the following question:
Shouldn't CanTaskBeCreatedByFactory
also take the parameters of the task into account for checking if the factory can be used for the requested task? If this would be a reasonable extension for this check I could open up a PR for MSBuild with such functionality if desired.
One Step Further:
When analyzing in MSBuild, what happens when one of the temp wpf projects is being processed... At some point you come to ProjectInstance.Initialize()
and then to Evaluator.Evaluate()
.
Within the Evaluate
method, a depth first search analysis is being performed. In pseudo, the order of files being analyzed in my case looks like this:
PerformDepthFirstPass
_projectRootElement:
D:\Temp\breuerTobiasRoslyn\roslyn\src\EditorFeatures\Core.Wpf\Microsoft.CodeAnalysis.EditorFeatures.Wpf_lhqn2mvh_wpftmp.csproj
EvaluateImportElement
"D:\\Temp\\breuerTobiasRoslyn\\roslyn\\src\\EditorFeatures\\Core.Wpf\\Microsoft.CodeAnalysis.EditorFeatures.Wpf_lhqn2mvh_wpftmp.csproj" #Children=12 DefaultTargets="" ToolsVersion="" InitialTargets="" ExplicitlyLoaded=false
PerformDepthFirstPass
"C:\\Program Files\\dotnet\\sdk\\2.2.100\\Sdks\\Microsoft.NET.Sdk\\Sdk\\Sdk.props" #Children=4 DefaultTargets="" ToolsVersion="" InitialTargets="" ExplicitlyLoaded=false
EvaluateImportElement
"C:\\Program Files\\dotnet\\sdk\\2.2.100\\Sdks\\Microsoft.NET.Sdk\\Sdk\\Sdk.props" #Children=4 DefaultTargets="" ToolsVersion="" InitialTargets="" ExplicitlyLoaded=false
PerformDepthFirstPass
"D:\\Temp\\breuerMsBuild\\msbuild\\artifacts\\bin\\bootstrap\\net472\\MSBuild\\Current\\Microsoft.Common.props" #Children=18 DefaultTargets="" ToolsVersion="4.0" InitialTargets="" ExplicitlyLoaded=false
EvaluateImportElement
"D:\\Temp\\breuerMsBuild\\msbuild\\artifacts\\bin\\bootstrap\\net472\\MSBuild\\Current\\Microsoft.Common.props" #Children=18 DefaultTargets="" ToolsVersion="4.0" InitialTargets="" ExplicitlyLoaded=false
PerformDepthFirstPass
"D:\\Temp\\breuerTobiasRoslyn\\roslyn\\Directory.Build.props" #Children=2 DefaultTargets="" ToolsVersion="" InitialTargets="" ExplicitlyLoaded=false
EvaluateImportElement
"D:\\Temp\\breuerTobiasRoslyn\\roslyn\\Directory.Build.props" #Children=2 DefaultTargets="" ToolsVersion="" InitialTargets="" ExplicitlyLoaded=false
PerformDepthFirstPass
"D:\\Caches\\nuget-cache\\microsoft.dotnet.arcade.sdk\\1.0.0-beta.19064.4\\Sdk\\Sdk.props" #Children=3 DefaultTargets="" ToolsVersion="" InitialTargets="" ExplicitlyLoaded=false
EvaluateImportElement
"D:\\Caches\\nuget-cache\\microsoft.dotnet.arcade.sdk\\1.0.0-beta.19064.4\\Sdk\\Sdk.props" #Children=3 DefaultTargets="" ToolsVersion="" InitialTargets="" ExplicitlyLoaded=false
PerformDepthFirstPass
"D:\\Caches\\nuget-cache\\microsoft.dotnet.arcade.sdk\\1.0.0-beta.19064.4\\tools\\Settings.props" #Children=11 DefaultTargets="" ToolsVersion="" InitialTargets="" ExplicitlyLoaded=false
EvaluateImportElement
"D:\\Caches\\nuget-cache\\microsoft.dotnet.arcade.sdk\\1.0.0-beta.19064.4\\tools\\Settings.props" #Children=11 DefaultTargets="" ToolsVersion="" InitialTargets="" ExplicitlyLoaded=false
PerformDepthFirstPass
"D:\\Temp\\breuerTobiasRoslyn\\roslyn\\artifacts\\obj\\Microsoft.CodeAnalysis.EditorFeatures.Wpf\\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj.nuget.g.props" #Children=3 DefaultTargets="" ToolsVersion="14.0" InitialTargets="" ExplicitlyLoaded=false
**EvaluateImportGroupElement
"D:\\Temp\\breuerTobiasRoslyn\\roslyn\\artifacts\\obj\\Microsoft.CodeAnalysis.EditorFeatures.Wpf\\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj.nuget.g.props" #Children=3 DefaultTargets="" ToolsVersion="14.0" InitialTargets="" ExplicitlyLoaded=false**
EvaluateImportElement
importElement = Project="$(NuGetPackageRoot)microsoft.net.compilers\\2.9.0-beta7-63018-03\\build\\Microsoft.Net.Compilers.props" Condition="Exists('$(NuGetPackageRoot)microsoft.net.compilers\\2.9.0-beta7-63018-03\\build\\Microsoft.Net.Compilers.props')"
PerformDepthFirstPass
"C:\\Users\\breuer_to\\.nuget\\packages\\microsoft.net.compilers\\2.9.0-beta7-63018-03\\build\\Microsoft.Net.Compilers.props" #Children=6 DefaultTargets="Build" ToolsVersion="15.0" InitialTargets="ValidateMSBuildToolsVersion" ExplicitlyLoaded=false
=> _usingTaskElements.Add "C:\\Users\\breuer_to\\.nuget\\packages\\microsoft.net.compilers\\2.9.0-beta7-63018-03\\build" For Task Csc.
To me it looks like the issue is in the D:\\Temp\\breuerTobiasRoslyn\\roslyn\\artifacts\\obj\\Microsoft.CodeAnalysis.EditorFeatures.Wpf\\Microsoft.CodeAnalysis.EditorFeatures.Wpf.csproj.nuget.g.props
file.
The content of this looks like this:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">D:\Temp\breuerTobiasRoslyn\roslyn\artifacts\obj\Microsoft.CodeAnalysis.EditorFeatures.Wpf\project.assets.json</ProjectAssetsFile>
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">$(UserProfile)\.nuget\packages\</NuGetPackageRoot>
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">C:\Users\breuer_to\.nuget\packages\</NuGetPackageFolders>
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">4.8.0</NuGetToolVersion>
</PropertyGroup>
<PropertyGroup>
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
</PropertyGroup>
<ImportGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
<Import Project="$(NuGetPackageRoot)xlifftasks\0.2.0-beta-63004-01\build\XliffTasks.props" Condition="Exists('$(NuGetPackageRoot)xlifftasks\0.2.0-beta-63004-01\build\XliffTasks.props')" />
<Import Project="$(NuGetPackageRoot)roslyn.diagnostics.analyzers\2.6.2-beta2\build\Roslyn.Diagnostics.Analyzers.props" Condition="Exists('$(NuGetPackageRoot)roslyn.diagnostics.analyzers\2.6.2-beta2\build\Roslyn.Diagnostics.Analyzers.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.sourcelink.common\1.0.0-beta2-18618-05\build\Microsoft.SourceLink.Common.props" Condition="Exists('$(NuGetPackageRoot)microsoft.sourcelink.common\1.0.0-beta2-18618-05\build\Microsoft.SourceLink.Common.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.build.tasks.git\1.0.0-beta2-18618-05\build\Microsoft.Build.Tasks.Git.props" Condition="Exists('$(NuGetPackageRoot)microsoft.build.tasks.git\1.0.0-beta2-18618-05\build\Microsoft.Build.Tasks.Git.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.sourcelink.vsts.git\1.0.0-beta2-18618-05\build\Microsoft.SourceLink.Vsts.Git.props" Condition="Exists('$(NuGetPackageRoot)microsoft.sourcelink.vsts.git\1.0.0-beta2-18618-05\build\Microsoft.SourceLink.Vsts.Git.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.sourcelink.github\1.0.0-beta2-18618-05\build\Microsoft.SourceLink.GitHub.props" Condition="Exists('$(NuGetPackageRoot)microsoft.sourcelink.github\1.0.0-beta2-18618-05\build\Microsoft.SourceLink.GitHub.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.netcore.analyzers\2.6.2-beta2\build\Microsoft.NetCore.Analyzers.props" Condition="Exists('$(NuGetPackageRoot)microsoft.netcore.analyzers\2.6.2-beta2\build\Microsoft.NetCore.Analyzers.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.net.compilers\2.9.0-beta7-63018-03\build\Microsoft.Net.Compilers.props" Condition="Exists('$(NuGetPackageRoot)microsoft.net.compilers\2.9.0-beta7-63018-03\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(NuGetPackageRoot)microsoft.codequality.analyzers\2.6.2-beta2\build\Microsoft.CodeQuality.Analyzers.props" Condition="Exists('$(NuGetPackageRoot)microsoft.codequality.analyzers\2.6.2-beta2\build\Microsoft.CodeQuality.Analyzers.props')" />
</ImportGroup>
</Project>
As one can see, this actually points to the nuget cache in my user profile storage. Therefor the Assembly located there is registered with the Csc task. And it is registered as the first candidate for the csc task in this case.
Well - I still don't know what this means and if this is the actual issue. I hope it helps though... I would still propose to extend the check for matching task factories, taking the parameters into account.,
@Pilchie Did we file a bug on WPF temp project not picking up NuGet targets? Can we dupe this against it.
I'm still hitting this.
Correction, I'm hitting a different error now, but still related to ValidateBootstrap
:
Build FAILED.
D:\repos\roslyn\eng\targets\Bootstrap.targets(4,5): error MSB4062: The "Microsoft.CodeAnalysis.BuildTasks.ValidateBootstrap" task could not be loaded from the assembly C:\Users\jcouv\.nuget\packages\microsoft.net.compilers.toolset\3.3.1-beta3-final\build\..\tasks\net472\Microsoft.Build.Tasks.CodeAnalysis.dll. Confirm that the <UsingTask> decl
aration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. [D:\repos\roslyn\src\Tools\Source\CompilerGeneratorTools\Source\CSharpErrorFactsGenerator\CSharpErrorFactsGenerator.csproj]
...
@jcouv
Hmm ... what that means is a node from msbuild is being re-used between builds. Do you happen to have Visual Studio opened? The scripts should be taking care of everything else ...
@jaredpar
The issue with build -bootstrap
I ran into this morning was fixed by adding -restore
. Thanks Andy for the tip
It sounds like this is resolved, so I will close this.
build.cmd -bootstrap
Tagging @RikkiGibson @jaredpar as FYI