Asp.net

如何在 .csproj 文件(而不是 project.json)中指定 ASP.NET Core 目標框架導入?

  • November 20, 2016

我正在建構一個 ASP.NET Core 應用程序,並嘗試安裝 Azure 儲存包。

從 Azure Storage github 頁面,它說我需要將以下內容放在我的 project.json 文件中 - 但由於這是使用最新的 ASP.NET Core 版本,我們沒有 project.json 文件,只有一個 .csproj文件。

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

有沒有辦法在 .csproj 文件中執行此操作?我認為這個地方可能在這個地方:

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

非常感謝!

將我的一個項目遷移到新模型後,它生成了以下內容:

<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>

嘗試以類似的方式添加 dnxcore50 和portable-net451+win8,如下所示:

<PropertyGroup>
   <OutputType>Exe</OutputType>
   <TargetFramework>netcoreapp1.1</TargetFramework>
   <PreserveCompilationContext>true</PreserveCompilationContext>
   <PackageTargetFallback Condition=" '$(TargetFramework)' == 'netcoreapp1.1' ">$(PackageTargetFallback);dnxcore50;portable-net451+win8</PackageTargetFallback>
</PropertyGroup>

引用自:https://stackoverflow.com/questions/40697420