Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify ASP.NET Core target framework imports in .csproj file (instead of project.json)?

I'm building an ASP.NET Core app, and am trying to install the Azure Storage package.

From the Azure Storage github page, it says I need to place the following in my project.json file - but since this is using the latest ASP.NET Core version, we don't have a project.json file, just a .csproj file.

"imports": [
    "dnxcore50",
    "portable-net451+win8"
  ]

Is there a way to do this in .csproj file? I assume the place might be somewhere around this:

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
  </PropertyGroup>

Thanks very much!

like image 931
Gabe Avatar asked Nov 19 '16 20:11

Gabe


People also ask

What is the purpose of the .csproj file?

csproj file to determine the packages to install from Nuget. To compile an ASP.NET application, the compiler needs information such as the version of the dotnet framework, the type of the application, etc. A . csproj file stores all this information that allows dotnet to build and compile the project.

How do I change my target framework to .NET 6?

To set target . NET runtime version to 6.0, enter <TargetFramework>net6. 0</TargetFramework> version in project's . csproj file directly.


1 Answers

After migrating one of my projects to the new model, this is what it generated:

<PropertyGroup>
    <TargetFramework>netcoreapp1.6</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <AssemblyName>TestApp</AssemblyName>
    <OutputType>Exe</OutputType>
    <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.6' ">$(PackageTargetFallback);dotnet5.6;portable-net45+win8</PackageTargetFallback>
</PropertyGroup>

Try adding dnxcore50 and portable-net451+win8 in a similar fashion, something like this:

<PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp1.1</TargetFramework>
    <PreserveCompilationContext>true</PreserveCompilationContext>
    <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">$(PackageTargetFallback);dnxcore50;portable-net451+win8</PackageTargetFallback>
</PropertyGroup>
like image 137
juunas Avatar answered Sep 19 '22 04:09

juunas