Jujur Sitanggang
Jujur Sitanggang

Reputation: 41

How to add the MVC Assemblies in the project.json File

I couldn't find the project.json file in my project, I create new project and I select empty and then I try to enabling ASP.NET core MVC, but I stuck to find a project.json to add this

"dependencies": {
 "Microsoft.NETCore.App": {
 "version": "1.0.0",
 "type": "platform"
 },
 "Microsoft.AspNetCore.Diagnostics": "1.0.0",
 "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
 "Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
 "Microsoft.Extensions.Logging.Console": "1.0.0",
 "Microsoft.AspNetCore.Mvc": "1.0.0"
}, 

How I get a project.json to add my code into project.json? BTW I try to study from this tutorial



[1]

Upvotes: 1

Views: 1347

Answers (1)

natemcmaster
natemcmaster

Reputation: 26773

Visual Studio 2017 does not support project.json files. To install any package (including MVC) to an existing project, you can do one of the following:

  1. Install via the NuGet Package Manager UI. In Solution Explorer, right click on "Project > References" and select "Manage NuGet Packages...". From there, you can browse to and install packages, such as the Microsoft.AspNetCore.Mvc package. See https://learn.microsoft.com/en-us/nuget/tools/package-manager-ui for more details. Repeat for all packages except Microsoft.NETCore.App.
  2. Install via Package Manager Console. Go to Tools > NuGet Package Manager > Package Manager Console. Then type the command Install-Package Microsoft.AspNetCore.Mvc. See https://learn.microsoft.com/en-us/nuget/tools/package-manager-console for more details. Repeat for all packages except Microsoft.NETCore.App.
  3. Finally, you can edit the csproj manually. In Solution Explorer, right click on your project name and go to "Edit (MyProject).csproj...". This will open a text editor where you can add the following code:

    <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.Diagnostics" Version="1.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Server.IISIntegration" Version="1.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="1.0.0" />
        <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.0.0" />
        <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="1.0.0" />
    </ItemGroup>

All of these are equivalent.

Upvotes: 1

Related Questions