dotnet / dotnet/project-system

Project.assets.json not updating when solution Platform changes

Open
#2,946 0 comments 0 reactions 0 assignees View on GitHub
Feature-NuGet Triage-Investigate
Dominant language
C#
Stars
1k
Forks
415
PR merge metrics
No merged PRs in 30d

Description

I have a .NET Framework (net452) application and I’m trying to target multiple architectures: x86/x64. I’m using the new .NET Core csproj format, and it’s been working fine. However, when I updated it to use x86;x64, it started to break. For class libraries, it doesn’t fill in a Runtime Identifier (RID), but for Exe/WinExe type projects, it automatically infers it from the platform. But MSBuild is not updating the project.assets.json when the platform changes.

Visual Studio Version: 15.4.2
.NET Core Version: 2.0.2

Here’s the relevant part of my .csproj file:

```

net452
WinExe
x86;x64

win10-$(Platform)

```

These are the steps I took and the results:

Launch Visual Studio. Default configuration is Debug/x86.
Build project.
project.assets.json has RID win10-x86
Build succeeds.

Change configuration to Debug/x64.
Build project.
project.assets.json has RID win10-x86
Build fails.

Rebuild project (clean/build)
project.assets.json has RID win10-x86
Build fails.

Right click solution -> Restore NuGet packages
Output shows:
```
Restoring NuGet packages...
All packages are already installed and there is nothing to restore.
```
project.assets.json has RID win10-x86

Close Visual Studio.
Relaunch, with Configuration still set to Debug/x64.
Build project.
project.assets.json has RID win10-x64
Build succeeds.

(Now here’s where it gets real funky 😋)

Run dotnet restore via command line*
project.assets.json has RID win10-AnyCPU (I’m assuming because the configuration information isn’t set)
Build project, with Configuration still set to Debug/x64
project.assets.json has RID win10-x86
Build fails.

Manually edit the project.assets.json file (remove, say, the “runtimes” property)
Build project, with Configuration still set to Debug/x64
project.assets.json is unmodified
Build fails (with the same error).

Right click solution -> Restore NuGet packages
Output shows:
```
Restoring NuGet packages...
All packages are already installed and there is nothing to restore.
```
project.assets.json is unmodified

Delete the project.assets.json file
Build project, with Configuration still set to Debug/x64
project.assets.json is regenerated with RID win10-x86
Build fails.

*Note: there are some errors from the dotnet restore command when referencing MSBuild specific files like Microsoft.CSharp.targets – not sure if it matters at least for the discussion around RID

It appears that Visual Studio seems to always regenerate the project.assets.json file on launch. It also seems to recognize that things are missing/changed when dotnet restore runs, but not when modifying the file manually. This kinda makes sense given the deletion scenario, since it seems like VS is caching the file and just repopulating it on disk.

Based on conversations offline, it sounds like **Platform is not triggering an update of NuGetRestore**. Someone more knowledgeable can probably go into more detail.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.