Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nuget 5.7 incompatible with VS 2019.8 #678

Closed
iskiselev opened this issue Nov 20, 2020 · 9 comments · Fixed by #701 or #725
Closed

Nuget 5.7 incompatible with VS 2019.8 #678

iskiselev opened this issue Nov 20, 2020 · 9 comments · Fixed by #701 or #725

Comments

@iskiselev
Copy link

Looks like currently mcr.microsoft.com/dotnet/framework/sdk:4.8 includes msbuild from Visual Studio 2019 Update 8 and NuGet 5.7. They are not compatible with each other - attempt to build project with VS msbuild after restoring with NuGet will result in errors like:
error NETSDK1005: Assets file '...\obj\project.assets.json' doesn't have a target for '...'. Ensure that restore has run and that you have included '...' in the TargetFrameworks for your project.

@iskiselev
Copy link
Author

NuGet should be update to 5.8 in docker images to solve the problem.

@mthalman
Copy link
Member

Verified this can repro with the following modifications to https://github.com/microsoft/dotnet-framework-docker/blob/d2b68d441d71df7615eeb8482419c2f975aa462e/samples/dotnetapp/Dockerfile:

Change dotnet restore to nuget restore here:

Change dotnet build to dotnet build --no-restore here:

It produces the following error:

C:\Program Files\dotnet\sdk\5.0.100\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets(241,5): error NETSDK1005: Assets file 'C:\app\dotnetapp\obj\project.assets.json' doesn't have a target for 'net48'. Ensure that restore has run and that you have included 'net48' in the TargetFrameworks for your project. [C:\app\dotnetapp\dotnetapp.csproj]

@MichaelSimons
Copy link
Member

There are a couple things we should check when fixing this issue:

  1. Make sure there are utests cover this scenario.
  2. Review the NuGet 5.8 release notes for breaking or impactful changes.

@mthalman
Copy link
Member

mthalman commented Dec 3, 2020

This applies to more than just an upgrade of NuGet 5.7 to 5.8. NuGet 5.7 is only installed in Server Core, version 2009/20H2. But the issue described here can occur on all currently supported Server Core versions which have a variety of NuGet versions installed. The reason they have different NuGet versions is because we've taken a conservative approach of changing the NuGet version in order to avoid any breaking changes. As each new version of Windows is released, we configure it to target the latest available NuGet version.

So in reality, this is more than just upgrading NuGet 5.7 to 5.8. It's about upgrading all the NuGet versions across all our supported SDK images to NuGet 5.8. The earliest version that we'd have to consider is 4.9. That's the version that Server Core 2019 LTSC is configured to use which is the most used version of our images. I'm still in the process of tracking down whether there are any breaking changes that would exist with such an upgrade.

@mthalman
Copy link
Member

mthalman commented Dec 3, 2020

I've gone through the list of DCRs in the release notes and haven't found any major breaking changes. I believe that normal NuGet CLI usage would continue to work. However, if there are dependencies directly on NuGet assemblies, consuming the API, there is the potential for breaking change. Most notably: NuGet/Home#7294.

I'm thinking that we might want to proceed more cautiously before making this change for the December update. I'd like to discuss things first with the NuGet team and figure out an upgrade strategy with them. Then we can create a proper announcement ahead of time with our plans.

In the mean time, the workaround would be to ensure that dotnet restore is used instead of nuget restore.

@iskiselev
Copy link
Author

It is not a problem for me right now, but using dotnet restore in place of nuget restore will not work for projects that still use packages.config: dotnet/sdk#7922. It makes restoring solution that contains both old and new project very tricky in sdk image until nuget will be updated.

@mthalman
Copy link
Member

If you make use of packages.config, you can use msbuild -t:restore -p:RestorePackagesConfig=true. That option is available in MSBuild 16.5+.

@mthalman
Copy link
Member

The latest set of images published as part of yesterday's Patch Tuesday release (#714) have included an additional version of nuget.exe (version 5.8) that is available from the following path: %ProgramFiles%\NuGet\latest\nuget.exe. For now, NuGet 5.7 is still available from %ProgramFiles%\NuGet\nuget.exe. This will be updated to 5.8 in the February release. See the following policy announcement for details on this change: #704.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants