NuGet during restore doesn't respect the same compat shims as MSBuild when running in VS 15 command prompt #3387

Closed
davkean opened this Issue Aug 30, 2016 · 8 comments

Comments

Projects
None yet
6 participants
@davkean

davkean commented Aug 30, 2016

We're running into restore issues under VS 15 with the new installer.

Basically, we're importing MIcrosoft.VS.SDK.targets via:

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

Under MSBuild.exe, this targets file will be looked for in two different paths:

C:\Program Files (x86)\Microsoft Visual Studio\VS15Preview\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK

-and-

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK (for compat)

It exists only in the former. Under NuGet.exe when running msbuild, this targets is looked under only in the compat path:

C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v15.0\VSSDK

This causes our build to fail in the new installer environment. NuGet should be respecting the same compat shims as MSBuild.

See: Microsoft/msbuild#954

@davkean davkean changed the title from NuGet during restore doesn't respect the same compat shims as MSBuild when running VS 15 to NuGet during restore doesn't respect the same compat shims as MSBuild when running in VS 15 command prompt Aug 30, 2016

@radical

This comment has been minimized.

Show comment
Hide comment
@radical

radical Aug 30, 2016

nuget.exe.config would need to add the search paths like (taken from https://github.com/Microsoft/msbuild/blob/xplat/src/XMakeCommandLine/app.config )

<configuration>
    <configSections>
      <section name="msbuildToolsets" type="Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </configSections>
...
<msbuildToolsets default="15.0">
      <toolset toolsVersion="15.0">
        <projectImportSearchPaths>
          <searchPaths os="windows">
            <property name="MSBuildExtensionsPath" value="$(MSBuildProgramFiles32)\MSBuild"/>
            <property name="MSBuildExtensionsPath32" value="$(MSBuildProgramFiles32)\MSBuild"/>
            <property name="MSBuildExtensionsPath64" value="$(MSBuildProgramFiles32)\MSBuild"/>
          </searchPaths>
        </projectImportSearchPaths>
      </toolset>
</msbuildToolsets>

...
</configuration>

The above sets the fallback search paths used for importing projects from $(MSBuildExtensionsPath). Any app hosting msbuild needs this to support the same search paths.

radical commented Aug 30, 2016

nuget.exe.config would need to add the search paths like (taken from https://github.com/Microsoft/msbuild/blob/xplat/src/XMakeCommandLine/app.config )

<configuration>
    <configSections>
      <section name="msbuildToolsets" type="Microsoft.Build.Evaluation.ToolsetConfigurationSection, Microsoft.Build, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    </configSections>
...
<msbuildToolsets default="15.0">
      <toolset toolsVersion="15.0">
        <projectImportSearchPaths>
          <searchPaths os="windows">
            <property name="MSBuildExtensionsPath" value="$(MSBuildProgramFiles32)\MSBuild"/>
            <property name="MSBuildExtensionsPath32" value="$(MSBuildProgramFiles32)\MSBuild"/>
            <property name="MSBuildExtensionsPath64" value="$(MSBuildProgramFiles32)\MSBuild"/>
          </searchPaths>
        </projectImportSearchPaths>
      </toolset>
</msbuildToolsets>

...
</configuration>

The above sets the fallback search paths used for importing projects from $(MSBuildExtensionsPath). Any app hosting msbuild needs this to support the same search paths.

@davkean davkean referenced this issue in dotnet/project-system Aug 30, 2016

Merged

Enable repro to build with new installer #410

@Sarabeth-Jaffe-Microsoft

This comment has been minimized.

Show comment
Hide comment
@Sarabeth-Jaffe-Microsoft

Sarabeth-Jaffe-Microsoft Aug 30, 2016

@radical The toolset which includes search paths is only loaded from msbuild.exe.config, so no need to add anything to nuget.exe.config.

@radical The toolset which includes search paths is only loaded from msbuild.exe.config, so no need to add anything to nuget.exe.config.

@radical

This comment has been minimized.

Show comment
Hide comment
@radical

radical Aug 30, 2016

Oh, I misunderstood then. I thought the program was hosting msbuild and so not running msbuild.exe .

radical commented Aug 30, 2016

Oh, I misunderstood then. I thought the program was hosting msbuild and so not running msbuild.exe .

@davkean

This comment has been minimized.

Show comment
Hide comment
@davkean

davkean Aug 30, 2016

This could be because NuGet is picking up the wrong/different version of MSBuild - and not the willow version. @Sarabeth-Jaffe-Microsoft Is there an environment variable to figure out what the "current" msbuild is?

davkean commented Aug 30, 2016

This could be because NuGet is picking up the wrong/different version of MSBuild - and not the willow version. @Sarabeth-Jaffe-Microsoft Is there an environment variable to figure out what the "current" msbuild is?

@Sarabeth-Jaffe-Microsoft

This comment has been minimized.

Show comment
Hide comment
@Sarabeth-Jaffe-Microsoft

Sarabeth-Jaffe-Microsoft Aug 31, 2016

@davkean There's no environment variable except for VSINSTALLDIR if you're in a VS command prompt. Willow provides a COM API that could be used to locate Willow and thus MSBuild.

@davkean There's no environment variable except for VSINSTALLDIR if you're in a VS command prompt. Willow provides a COM API that could be used to locate Willow and thus MSBuild.

@rrelyea rrelyea added this to the 3.6 Beta1 milestone Sep 1, 2016

@rrelyea

This comment has been minimized.

Show comment
Hide comment
@rrelyea

rrelyea Sep 1, 2016

Contributor

We are working to incorporate that COM API now. Assigning this bug to @drewgil, as he is doing that work.

Contributor

rrelyea commented Sep 1, 2016

We are working to incorporate that COM API now. Assigning this bug to @drewgil, as he is doing that work.

@rrelyea rrelyea modified the milestones: 3.6 Beta1, 3.6 Beta2 Sep 22, 2016

@rrelyea rrelyea modified the milestones: 4.0 RC2, 4.0 RC Oct 27, 2016

@rrelyea rrelyea modified the milestones: 4.0 RC2, 4.0 RC3 Nov 29, 2016

@drewgillies drewgillies removed their assignment Dec 20, 2016

@rrelyea

This comment has been minimized.

Show comment
Hide comment
@rrelyea

rrelyea Jan 3, 2017

Contributor

@nkolev92 - With Drew's work finished to properly find msbuild.exe in VS 2017 installs, this should be fixed now. Can you please confirm?

Contributor

rrelyea commented Jan 3, 2017

@nkolev92 - With Drew's work finished to properly find msbuild.exe in VS 2017 installs, this should be fixed now. Can you please confirm?

@nkolev92

This comment has been minimized.

Show comment
Hide comment
@nkolev92

nkolev92 Jan 4, 2017

Member

Looks good.

Tested with:
NuGet version: 4.0.0-RC3-2162
OS version: Windows 10 RS1_Release 14393.693

Member

nkolev92 commented Jan 4, 2017

Looks good.

Tested with:
NuGet version: 4.0.0-RC3-2162
OS version: Windows 10 RS1_Release 14393.693

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment