Is 'Microsoft.AspNetCore.Razor.Tools' obsolete for .net core 3.1? Then which package to use instead?

Viewed 791

I am starting a new project in ASP.NET Core 3.1. In the model project they used these 3 packages in project_name.json file:

"Microsoft.AspNetCore.Razor.Tools ": { "version": "1.0.0-preview2-final", "type": "build" },

"Microsoft.AspNetCore.StaticFiles": "1.0.0",

"Microsoft.AspNetCore.Mvc": "1.0.1"

And there was a tools section in project_name.json file:

"tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final", "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final"}

which adds ' "Microsoft.AspNetCore.Razor.Tools": "1.0.0-preview2-final" '.


I want to install the packages from NuGet package manager simply. But I am not finding:

Microsoft.AspNetCore.Razor.Tools

package there. I looked out what's its replacement but didn't come up with one.

And, there was a package 'Microsoft.AspNetCore.Mvc.Core' that I replaced for ' "Microsoft.AspNetCore.Mvc": "1.0.1" '.

So, the questions are,

  1. What is the replacement for 'Microsoft.AspNetCore.Razor.Tools'? Is the package like 'Microsoft.AspNetCore.Razor' in NuGet the replacement? Or should I add it manually in .csproj? If 'yes' then I think that the package is a little outdated as it last was updated in 2016. And, can I do that manually in .csproj as I can do in project_name.json?

  2. How to configure the tools section? As there are no tools section now in the .csproj file like project_name.json file has.

  3. Is 'Microsoft.AspNetCore.Mvc.Core' is replacment for 'Microsoft.AspNetCore.Mvc'?

Thank you.

1 Answers

What is the replacement for 'Microsoft.AspNetCore.Razor.Tools'? Is the package like 'Microsoft.AspNetCore.Razor' in NuGet the replacement? Or should I add it manually in .csproj? If 'yes' then I think that the package is a little outdated as it last was updated in 2016. And, can I do that manually in .csproj as I can do in project_name.json?

Actually, the package Microsoft.AspNetCore.Razor.Tools exists under nuget.org and it is just a preview version.

In Nuget package management UI, it has a set switch to separate the official and preview nuget packages.

You can refer to this:

enter image description here

Besides, you can add reference node directly in xxx.csproj file. The UI function is just download the related nuget package into the local and then modify xxx.csproj to add the Reference elements.

Add like these in your xxx.csproj:

<ItemGroup>   
    <PackageReference Include="Microsoft.AspNetCore.Razor.Tools" Version="1.0.0-preview2-final" />    
</ItemGroup>

How to configure the tools section? As there are no tools section now in the .csproj file like project_name.json file has.

So far, the latest Net Core does not support project.json format.Instead, they migrate it into xxx.csproj file.

So in the new Net Core 3.1 project, you should change xxx.csproj to add them.

This document shows how to migrate each node in project.json file to xxx.csproj file.

About tools section, you can see this, use DotNetCliToolReference selection in xxx.csproj file.

Solution

For your issue, you should add like this in your xxx.csproj file:

<ItemGroup>
  <DotNetCliToolReference Include="Microsoft.AspNetCore.Server.IISIntegration.Tools" Version="1.0.0-preview2-final" />
</ItemGroup>

Then you can use it.

Is 'Microsoft.AspNetCore.Mvc.Core' is replacment for 'Microsoft.AspNetCore.Mvc'?

They are quite different from each other. Each has its own feature.

Related