Aspnetcore: Converting a .csproj to .xproj RC2

Created on 17 May 2016  路  4Comments  路  Source: dotnet/aspnetcore

This steps will get you on the success path of migrating a csproj to xproj using framework net451.

1 Delete csproj file.
2 rename package.config to project.json
3 edit project.json as follows:

Imagine you have this content:

<?xml version="1.0" encoding="utf-8"?>
<packages>
  <package id="Newtonsoft.Json" version="8.0.3" targetFramework="net451" />
  <package id="SomeCoolPackage" version="3.0.1" targetFramework="net451" />
</packages>

Update it so it became:

{
  "dependencies": {
    "SomeCoolPackage": "3.0.1",
    "Newtonsoft.Json": "8.0.3"
  },
  "frameworks": {
    "net45": {
    }
  },
  "runtimes": {
    "win": { }
  }
}
  • run dotnet restore
  • run dotnet build

You may find some errors, for example missing some framework assemblies.

Take note of which assemblies are missing and add them as follows:

{
  "dependencies": {
    "SomeCoolPackage": "3.0.1",
    "Newtonsoft.Json": "8.0.3"
  },
  "frameworks": {
 "net45": {
      "frameworkAssemblies": {
        "System.Runtime.Serialization": "4.0.0.0",
      }
    }
  },
  "runtimes": {
    "win": { }
  }
}

DONE. ;) Enjoy the new world.

Most helpful comment

Unless i'm missing something, this doesn't create a .xproj file?

In order to create the xproj: Start visual studio and add existing project - select the project.json file. This will create the xproj.

All 4 comments

This was really helpful

Unless i'm missing something, this doesn't create a .xproj file?

In order to create the xproj: Start visual studio and add existing project - select the project.json file. This will create the xproj.

Life saver. Thank you.

This issue is being closed because it has not been updated in 3 months.

We apologize if this causes any inconvenience. We ask that if you are still encountering this issue, please log a new issue with updated information and we will investigate.

Was this page helpful?
0 / 5 - 0 ratings