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

3

23

I did not find project.json in visual studio 2017 RC. Has this been removed in this version or am i missing something ? How do they store list of dependencies now if it is removed ?

Ibeam answered 20/11, 2016 at 0:31 Comment(0)
U
46

Going forward, .Net Core is going to be based on msbuild, which means that it's going to use *.csproj instead of project.json. Package references are now also stored in the *.csproj file.

For more information, read Announcing .NET Core Tools MSBuild “alpha” on the .NET Blog and High level overview of changes in CLI Preview 3 in .NET Documentation.

For example, if you had this in your project.json:

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

You will now have *.csproj containing:

<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>
Uprear answered 20/11, 2016 at 2:53 Comment(6)
I'm sure there is a valid reason for switching from project.json to *.csproj, but from where I'm sitting... project.json is about 10 times easier to comprehend at a glance from a coding perspective...Plebeian
@KevinFrancis Keep in mind that the csproj fragment I showed here is outdated. You no longer reference Microsoft.NETCore.App, the SDK is just a single attribute on the root element and package versions can be specified using an attribute. In my opinion, even if you dislike the XML syntax, the increased power and unification with all other project types is worth it.Uprear
@Uprear Do you know where I specify that I want to create an exe-file out of my console app after this change? Before, you could do this in project.json. Right now, compiling my console app only creates a DLL in the /Debug folder.Fourwheeler
@Fourwheeler If you want to do a self-contained deployment, then you need to specify <RuntimeIdentifiers> in your csproj and then use dotnet publish for that RID.Uprear
@Uprear Isn't it a bit hacky to have to change the csproj externally?Fourwheeler
@Fourwheeler I don't think so. 1. I believe it's the only choice here. 2. There was a lot of effort spent on making csprojs manually editable (including making the files simpler and being able to open the csproj in VS without unloading the project).Uprear
G
3

Refer Given Link

https://learn.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>
Gustie answered 12/7, 2017 at 10:41 Comment(0)
S
3

In Solution Explorer:

  1. Right Click on the Project
  2. Select Edit (YourProjectNameHere).csproj

A window should appear allowing you to view the XML version of the .csproj. The dependencies will be listed here under the PackageReference description.

Shull answered 26/9, 2017 at 10:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.