dotnet / msbuild

The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
https://docs.microsoft.com/visualstudio/msbuild/msbuild
MIT License
5.21k stars 1.35k forks source link

Willow MSBuild does not look up MSBuild extension path under VS folder when using MSBuildExtensionPath32 #954

Closed davkean closed 8 years ago

davkean commented 8 years ago

Running from a Willow command-prompt, with the following variations of imports:

  <VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
[...]
   <Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets"" />
<Import Project="$(VSToolsPath)\VSSDK\Microsoft.VsSDK.targets" />

and

<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\VSSDK\Microsoft.VsSDK.targets"/>

Under a Willow command-prompt, I would expect all of these to get found under C:\Program Files (x86)\Microsoft Visual Studio 15.0\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK.

Instead I get:

D:\roslyn-project-system\build\Targets\VSL.Imports.targets(368,3): error MSB4019: The imported project "C:\Program File
s (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" was not found. Confirm that the path in the
 <Import> declaration is correct, and that the file exists on disk. [D:\roslyn-project-system\src\ProjectSystemDogfoodS
etup\ProjectSystemDogfoodSetup.csproj] [D:\roslyn-project-system\build\build.proj]
davkean commented 8 years ago

This might be because VsInstallRoot isn't set? Can't figure out how this calculated.

davkean commented 8 years ago

VSInstallRoot looks like it respects VSINSTALLDIR if VisualStudioVersion is also set: https://github.com/Microsoft/msbuild/blob/60c73c914c01c62f5496c6d04683f77e967bbc68/src/Shared/BuildEnvironmentHelper.cs#L166.

Tried this, still didn't work.

davkean commented 8 years ago

Oh, I looked at the log - turns out this is NuGet.exe running MSBuild:

                   Using "Exec" task from assembly "Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
                   Task "Exec" (TaskId:3)
                     Task Parameter:Command="C:\roslyn-project-system\build\..\build\bin\NuGet.exe" restore -verbosity quiet "C:\roslyn-project-system\build\..\src\ProjectSystem.sln" (TaskId:3)
                     "C:\roslyn-project-system\build\..\build\bin\NuGet.exe" restore -verbosity quiet "C:\roslyn-project-system\build\..\src\ProjectSystem.sln" (TaskId:3)
18:34:52.092     1>C:\roslyn-project-system\build\Targets\VSL.Imports.targets(365,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\roslyn-project-system\src\Microsoft.VisualStudio.ProjectSystem.CSharp.VS\Microsoft.VisualStudio.ProjectSystem.CSharp.VS.csproj] [C:\roslyn-project-system\build\build.proj]
18:34:52.190     1>C:\roslyn-project-system\build\Targets\VSL.Imports.targets(365,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\roslyn-project-system\src\Microsoft.VisualStudio.ProjectSystem.VisualBasic.VS\Microsoft.VisualStudio.ProjectSystem.VisualBasic.VS.csproj] [C:\roslyn-project-system\build\build.proj]
18:34:52.304     1>C:\roslyn-project-system\build\Targets\VSL.Imports.targets(365,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\roslyn-project-system\src\Microsoft.VisualStudio.ProjectSystem.CSharp.VS\Microsoft.VisualStudio.ProjectSystem.CSharp.VS.csproj] [C:\roslyn-project-system\build\build.proj]
18:34:52.322     1>C:\roslyn-project-system\build\Targets\VSL.Imports.targets(365,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\roslyn-project-system\src\Microsoft.VisualStudio.ProjectSystem.CSharp.VS\Microsoft.VisualStudio.ProjectSystem.CSharp.VS.csproj] [C:\roslyn-project-system\build\build.proj]
18:34:52.438     1>C:\roslyn-project-system\build\Targets\VSL.Imports.targets(365,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\roslyn-project-system\src\Microsoft.VisualStudio.ProjectSystem.VisualBasic.VS\Microsoft.VisualStudio.ProjectSystem.VisualBasic.VS.csproj] [C:\roslyn-project-system\build\build.proj]
18:34:52.458     1>C:\roslyn-project-system\build\Targets\VSL.Imports.targets(365,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\roslyn-project-system\src\Microsoft.VisualStudio.ProjectSystem.VisualBasic.VS\Microsoft.VisualStudio.ProjectSystem.VisualBasic.VS.csproj] [C:\roslyn-project-system\build\build.proj]
18:34:52.472     1>C:\roslyn-project-system\build\Targets\VSL.Imports.targets(365,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\roslyn-project-system\src\ProjectSystemSetup\ProjectSystemSetup.csproj] [C:\roslyn-project-system\build\build.proj]
18:34:52.480     1>C:\roslyn-project-system\build\Targets\VSL.Imports.targets(365,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\roslyn-project-system\src\VisualStudioEditorsSetup\VisualStudioEditorsSetup.csproj] [C:\roslyn-project-system\build\build.proj]
18:34:52.631     1>C:\roslyn-project-system\build\Targets\VSL.Imports.targets(365,3): error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK\Microsoft.VsSDK.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk. [C:\roslyn-project-system\src\ProjectSystemDogfoodSetup\ProjectSystemDogfoodSetup.csproj] [C:\roslyn-project-system\build\build.proj]
                      (TaskId:3)
18:34:52.674     1>C:\roslyn-project-system\build\build.proj(30,5): error MSB3073: The command ""C:\roslyn-project-system\build\..\build\bin\NuGet.exe" restore -verbosity quiet "C:\roslyn-project-system\build\..\src\ProjectSystem.sln"" exited with code 1.
                   Done executing task "Exec" -- FAILED. (TaskId:3)
18:34:52.674     1>Done building target "RestorePackages" in project "build.proj" -- FAILED.: (TargetId:2)
18:34:52.675     1>Done Building Project "C:\roslyn-project-system\build\build.proj" (Build target(s)) -- FAILED.
davkean commented 8 years ago

Filed this against NuGet: https://github.com/NuGet/Home/issues/3387.