-
Notifications
You must be signed in to change notification settings - Fork 383
Description
I noticed something weird in microsoft.dotnet.arcade.sdk\1.0.0-beta.20215.5\tools\Build.proj:
arcade/src/Microsoft.DotNet.Arcade.Sdk/tools/Build.proj
Lines 86 to 87 in 62fc25d
| <_NuGetRestoreTargets>$(MSBuildToolsPath)\NuGet.targets</_NuGetRestoreTargets> | |
| <_NuGetRestoreTargets Condition="'$([MSBuild]::IsRunningFromVisualStudio())' == 'true'">$(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets</_NuGetRestoreTargets> |
NuGetRestoreTargets is set to:
<_NuGetRestoreTargets>$(MSBuildToolsPath)\NuGet.targets</_NuGetRestoreTargets>
<_NuGetRestoreTargets Condition="'$([MSBuild]::IsRunningFromVisualStudio())' == 'true'">$(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets</_NuGetRestoreTargets>
As far as I can tell, the MSBuildToolsPath is always:
MSBuildToolsPath = C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Current\Bin
In regular builds it is set like this in Microsoft.Common.CurrentVersion.targets:
<NuGetRestoreTargets Condition="'$(NuGetRestoreTargets)'=='' and '$([MSBuild]::IsRunningFromVisualStudio())'=='true'">$(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets</NuGetRestoreTargets>
<NuGetRestoreTargets Condition="'$(NuGetRestoreTargets)'==''">$(MSBuildToolsPath)\NuGet.targets</NuGetRestoreTargets>
Basically NuGet.targets is never in the same directory as MSBuild.exe as far as I can tell, so Arcade sets it to the wrong location. I don't know why it's currently setting it to $(MSBuildToolsPath)\NuGet.targets but it should probably just remove this line and always set it to $(MSBuildToolsPath32)\..\..\..\Common7\IDE\CommonExtensions\Microsoft\NuGet\NuGet.targets?
My repro: I was building Roslyn.sln with a path set to custom MSBuild:
- git clone https://github.com/dotnet/roslyn
- restore
- In a regular command prompt (with fresh environment):
set PATH=C:\roslyn\.dotnet;C:\msbuild\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin;%PATH%
and it failed with:
import not found C:\msbuild\artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\NuGet.targets
However I have to say that the failure is not deterministic so I was unable to reproduce since. Just wondering how it works though.