SHIN JaeGuk
SHIN JaeGuk

Reputation: 511

How to change UWP app folder name or path?

Renaming UWP app folder or changing its path cause an error which is 'Some assembly references are missing. Building to restore the NuGet cache might resolve this issue.'

When I create UWP app folder I can see Microsoft.NETCore.UniversalWindowsPlatform NuGet package in references node of Solution Explorer but after renaming or moving the folder there is no NuGet package in the node.

I tried building and clearing NuGet cache but nothing changes. 2 options of Package Restore are checked as default. In the case of Windows Forms App with NuGet package, the error is not reproduced. How can I solve the problem?

Upvotes: 0

Views: 841

Answers (1)

Martin Zikmund
Martin Zikmund

Reputation: 39072

The problem lies in the temporary files generated by Visual Studio. If you open the obj folder in the UWP project, you will find several files related to NuGet there. The one that causes your problem is {AppName}.csproj.nuget.g.props. You can see that inside of this file there is an absolute path to the project.assets.json file:

<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">D:\PathToFile\obj\project.assets.json</ProjectAssetsFile>

This becomes a problem when you move the solution to another path because this path is no longer valid and is therefore unusable.

The solution is quite simple - close Visual Studio and delete the bin and obj folders from your UWP project.

As a tip - install the awesome Clean Solution extension for Visual Studio by Mads Kristensen. This extension automatically performs a cleanup each time you close Visual Studio - it collapses all folders in the solution and also deletes bin and obj folders for each project, so you are starting with a clean slate each time.

Upvotes: 1

Related Questions