project.json 未在 Visual Studio 2017 RC 解决方案资源管理器中找到

project.json Not Found in Visual Studio 2017 RC Solution Explorer

我在 visual studio 2017 RC 中没有找到 project.json。这是否已在此版本中删除,还是我遗漏了什么?如果删除了依赖项列表,他们现在如何存储?

展望未来,.Net Core 将基于 msbuild,这意味着它将使用 *.csproj 而不是 project.json。包引用现在也存储在 *.csproj 文件中。

有关详细信息,请阅读 Announcing .NET Core Tools MSBuild “alpha” on the .NET Blog and High level overview of changes in CLI Preview 3 in .NET Documentation

例如,如果您的project.json中有这个:

"dependencies": {
  "Microsoft.NETCore.App": {
    "type": "platform",
    "version": "1.0.0"
  },
  "Newtonsoft.Json": "9.0.1"
}

您现在将拥有包含以下内容的 *.csproj:

<PackageReference Include="Microsoft.NETCore.App">
  <Version>1.0.1</Version>
</PackageReference>
<PackageReference Include="Microsoft.NET.Sdk">
  <Version>1.0.0-alpha-20161104-2</Version>
  <PrivateAssets>All</PrivateAssets>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
  <Version>9.0.1</Version>
</PackageReference>

参考给定 Link

https://docs.microsoft.com/en-us/dotnet/core/tools/project-json-to-csproj

Project.json

{
  "buildOptions": {
    "warningsAsErrors": true,
    "nowarn": ["CS0168", "CS0219"],
    "xmlDoc": true,
    "preserveCompilationContext": true,
    "outputName": "Different.AssemblyName",
    "debugType": "portable",
    "allowUnsafe": true,
    "define": ["TEST", "OTHERCONDITION"]
  }
}

Solution->Right Click ->Edit Project.csporj

<PropertyGroup>
  <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
  <NoWarn>$(NoWarn);CS0168;CS0219</NoWarn>
  <GenerateDocumentationFile>true</GenerateDocumentationFile>
  <PreserveCompilationContext>true</PreserveCompilationContext>
  <AssemblyName>Different.AssemblyName</AssemblyName>
  <DebugType>portable</DebugType>
  <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  <DefineConstants>$(DefineConstants);TEST;OTHERCONDITION</DefineConstants>
</PropertyGroup>

在解决方案资源管理器中:

  1. 右键单击项目
  2. Select 编辑 (YourProjectNameHere).csproj

应该会出现一个 window,让您可以查看 .csproj 的 XML 版本。依赖项将在此处的 PackageReference 描述下列出。