Migrate legacy UWP project system to MSBuild-based
When Microsoft decided to adopt MSBuild on .NET Core platform, project.json was not dropped immediately until first toolchain RTM arrives. Dotnet Development on Universal Windows Platform Development leverages .NET Core too, but the depreciation progress is significantly slower than other .NET Core platforms due to historical reasons. UWP uses project.json for package management and MSBuild for builds.
In Visual Studio 2017 April Update, Microsoft finally migrates new UWP projects to full MSBuild-based project system. But our projects, which creates on early 2015, doesn’t get an auto migration as expected. Hence we decided to migrate them manually for additional benefits like better toolchain stability and advanced customization features. Reminder: Do not attempt to use “dotnet migrate” CLI command, it won’t work for UWP projects.
Migration Prerequisites
- Notify all your team members. Make sure everyone has Visual Studio 2017 with April update installed.
- If you have continuous integration environment configured, make sure build agents have NuGet 4.1 or higher installed (3.5 or 4.0 won’t work).
- Lock VCS during migration to prevent additional incidents. (We’re using TFVC for source management so that it will be easy)
Migration
Clean up all projects (including bin and obj directories)
Iterate all project directories
Find C# project file, open with your favorite editor.
Add following property group before project file lists:
PackageReference
Okay, you’ve completed the first step. Then open your project.json file. Migrate all NuGet packages references as the picture below.
Package Reference
Finally, remove project.json
and additional files like project.lock.json
, *.nuget.targets
, *.nuget.props
. (Or your will get lots of warning that may lead .NET Native compilation fail) Do it for every project. Then open Visual Studio, restore NuGet packages for all projects, build to validate and submit changes.