sdk: Unable to migrate multi-project solution to Asp.net Core 1.1

Migration tool does not seem to support multiple project solutions well.

ReciPiBook.Api Message src\ReciPiBook.Api\ReciPiBook.Api.xproj: Failed to migrate XProj project ReciPiBook.Api. ‘dotnet migrate -s -p “C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api” -x “C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api\ReciPiBook.Api.xproj”’ exited with error code 1. src\ReciPiBook.Api\ReciPiBook.Api.xproj: Could not find file ‘C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Services\project.json’. Migration failed. src\ReciPiBook.Api\ReciPiBook.Api.xproj: Backing up C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api\ReciPiBook.Api.xproj to C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\Backup\src\ReciPiBook.Api\ReciPiBook.Api.xproj. src\ReciPiBook.Api\project.json: Backing up C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\src\ReciPiBook.Api\project.json to C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook2017\ReciPiBookCore\Backup\src\ReciPiBook.Api\project.json.

Steps to reproduce

Clone https://github.com/napalm684/ReciPiBookCore Open in vs2017rc or run migration command

Expected behavior

Migration tools succeed or provide feedback on why it failed/steps to correct.

Actual behavior

Failures without clear reason (see errors above)/unable to even recreate the projects manually nuget packages will install in the projects (ie: Microsoft.AspNetCore.Mvc in the ReciPiBook.Api project) but are not recognized by the compiler.

Environment data

dotnet --info output:

C:\Users\xxx>dotnet --info .NET Command Line Tools (1.0.0-preview3-004056)

Product Information: Version: 1.0.0-preview3-004056 Commit SHA-1 hash: ccc4968bc3

Runtime Environment: OS Name: Windows OS Version: 10.0.14393 OS Platform: Windows RID: win10-x64

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 7
  • Comments: 28 (7 by maintainers)

Most upvoted comments

I got my project working in VS2017RC (finally). Here’s the process I followed:

  1. Followed steps 1 and 2 of the ASP.NET Core 1.1 upgrade instructions on the blog (install SDK 1.1 and edit the Web project.json). I also installed the “Visual Studio 2015 Tools (Preview 2)” from the .NET Core downloads page page - I’m not sure which order I did these in or if it matters.
  2. Load the solution in VS2015.
  3. Instead of using the UI NuGet updater (step 3 in the blog post) I just ran Update-Package in the package console.
  4. Debug the project to verify everything works, then exit VS2015.
  5. Edit the global.json file and set the SDK version to 1.0.0-preview3-004056 (this is the version that dotnet --info says I have installed).
  6. dotnet migrate and then dotnet restore.
  7. Remove all project.json and *.xproj files from the project tree.
  8. Open the solution in VS2017RC.

It even runs on the Mac preview of VS2017RC but none of the dotnet ef commands work, they still expect a project.json file.

I have seen the same issue when migrating a solution to VS 2017 RC: in the solution there are projects A and B, B depends on A. Project A is migrated successfully and its project.json is moved, then when it tries to convert project B, it looks for project A’s project.json, but it’s not there since it was already moved. There are three issues:

  • failure to migrate when there are projects in solution than depend on one another
  • does not provide clear message why migration did not succeed: the error message is “dotnet migrate exited with error code 1.” There is a message about not finding a project.json file, but it appears as a separate warning
  • after failure to migrate, the solution is left in an inconsistent state from where is hard to go back to VS 2015

Repro: https://github.com/lucabol/FollowTheGuru , open in VS 2017 RC

Some suggestions after having gone through this process a couple times:

  • It seems like VS2017RC should throw up a warning if the project is not targeting .NET Core 1.1 and either provide instructions for upgrading to 1.1 or at least link to the blog post with upgrade steps.
  • When doing the migration VS2017RC should do it from the parent directory to avoid the situation where multi-project solutions get hung up or at least pop up a warning suggesting to the user that they dotnet migrate themselves from the solution directory (if it’s a multi-project solution) to avoid this issue.

I’m seeing the same issues.

  1. Running dotnet migrate from the directory the solution is in seems to create the .csproj files as @piotrpMSFT says.
  2. It does not update the solution - when opened in VS2017RC it asks to ‘One-way upgrade’ them all again which gives a failure.
  3. Once I remove all the non-functional .xproj files from the solution and add the .csproj files nothing works, there are a ton of errors.
  4. My Web project icon is the “class library” project icon when I re-add it.

Is the migration supposed to handle the items covered in the instructions for upgrading to ASP.NET Core 1.1 on the blog or do those steps need to be done manually?

@piotrpMSFT So I attempted suggestion one and the migration returned 8 of 8 migrated projects in the output.

C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook>dotnet migrate Project ReciPiBook.Api migration succeeded (C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook\ReciPiBookCore\src\ReciPiBook.Api) Project ReciPiBook.Client migration succeeded (C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook\ReciPiBookCore\src\ReciPiBook.Client) Project ReciPiBook.Di migration succeeded (C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook\ReciPiBookCore\src\ReciPiBook.Di) Project ReciPiBook.Dtos migration succeeded (C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook\ReciPiBookCore\src\ReciPiBook.Dtos) Project ReciPiBook.Entities migration succeeded (C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook\ReciPiBookCore\src\ReciPiBook.Entities) Project ReciPiBook.Repository migration succeeded (C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook\ReciPiBookCore\src\ReciPiBook.Repository) Project ReciPiBook.Services migration succeeded (C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook\ReciPiBookCore\src\ReciPiBook.Services) Project ReciPiBook.Translators migration succeeded (C:\Users\xxx\Documents\Visual Studio 2015\Projects\ReciPiBook\ReciPiBookCore\src\ReciPiBook.Translators) Summary Total Projects: 8 Succeeded Projects: 8 Failed Projects: 0

But when I opened visual studio 2017 rc it still prompted me that the projects needed migrated which resulted in all projects failing this pass. So I attempted it again not migrating when the popup came up and the projects wouldn’t load designating each one in solution explorer as Migration Needed.

_EDIT_ I then noticed xproj was in the solution file so I updated to csproj. All projects are unable to be loaded with an unspecified error per visual studio.

In trying suggestion two, I am cd’d into the project directory so for example ReciPiBook.Dtos. Running dotnet migrate results in “No executable found matching dotnet-migrate”

As for the nuget re-creation no I do not have that in my repo. I can attempt that if needed I just think it feels like a side-effect of the failed migration? But let me know if you would like it anyway.

For the project-to-project dependencies, you have two options:

  1. Recommended: run migration from the parent directory of the projects. No arguments needed. Migrate will scan the child directories and migrate while preserving context, then clean up only once migration has fully completed.
  2. Migrate the projects individually, but pass --skip-backup so the project.json files are left behind. Then manually clean up these files.

If Migrate is pointed to a leaf-node project then it assumes it’s done everything necessary and cleans up the PJ contents. It doesn’t have enough data to know better. The project.json file structure was quite implicit so there’s not an explicit description of what all is dependent on a given library.

We’re thinking of adding a message on missing project.json files to say “You may have migrated a dependency project independently. Please revert that migration, or copy the artifacts from the generated backup directory to enable migration of dependent projects. We recommend running migrate from a parent directory when migrating multi-project solutions.” Thoughts?

You can see the error if you run the dotnet migrate command manually from each project directory - it’s prematurely discarding the project.json file during conversion (it saves a backup you can put back in place).

I manually upgraded each project in my solution to get around this issue and then ran into another one.