将Visual Studio项目转换为Dot Net Core项目 csproj to xproj

  1. 删除csproj文件。
  2. 将 package.config 重命名为 project.json 。
  3. 转换文件,将xml转换为json格式。
  4. <?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>

    转换之后

    {
      "dependencies": {
        "SomeCoolPackage": "3.0.1",
        "Newtonsoft.Json": "8.0.3"
      },
      "frameworks": {
        "net45": {
        }
      },
      "runtimes": {
        "win": { }
      }
    }
  5. 执行 dotnet restore
  6. 执行 dotnet build
  7. 你可能会遇到错误,尝试添加对Frmework的引用
    {
      "dependencies": {
        "SomeCoolPackage": "3.0.1",
        "Newtonsoft.Json": "8.0.3"
      },
      "frameworks": {
     "net45": {
          "frameworkAssemblies": {
            "System.Runtime.Serialization": "4.0.0.0",
          }
        }
      },
      "runtimes": {
        "win": { }
      }
    }
  8. 打开Visual Studio,添加现有项目。
原文地址:https://www.cnblogs.com/Soar1991/p/5635645.html