簡體   English   中英

Azure Cloud Service Classic with .NET Standard目標

[英]Azure Cloud Service Classic with .NET Standard target

有沒有辦法如何使用針對.netstandard2.0的輔助角色運行Azure Cloud Service Classic項目?

我有這樣的項目,但任何時候我嘗試構建它我收到此錯誤:

嚴重級代碼描述項目文件行抑制狀態錯誤項目'C:\\ path \\ to \\ project \\ src \\ Frontend \\ Frontend.csproj'目標'.NETStandard,版本= v2.0'。 它不能被針對'.NETFramework,Version = v4.0'的項目引用。 UserDiscoveryService C:\\ Program Files \\ dotnet \\ sdk \\ 2.0.2 \\ Sdks \\ Microsoft.NET.Sdk \\ build \\ Microsoft.NET.Sdk.Common.targets 87

我試圖在ccproj中設置目標框架,但它沒有幫助我。

為了防止其他人遇到這個問題,我通過將此行添加到雲服務.ccproj文件的Project / PropertyGroup部分來解決此錯誤: <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>

例如

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>2.9</ProductVersion>
    <ProjectGuid>8c99xxxx-xxxx-xxxx-xxxx-xxxxxxxx273e</ProjectGuid>
    <OutputType>Library</OutputType>
    <AppDesignerFolder>Properties</AppDesignerFolder>
    <RootNamespace>MyCloudService</RootNamespace>
    <AssemblyName>MyCloudService</AssemblyName>
    <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> <!-- Added -->
    <StartDevelopmentStorage>True</StartDevelopmentStorage>
    <Name>CloudSheetCloudService</Name>
    etc...

默認情況下,雲服務項目不指定框架(它不需要),但MSBuild中的某些內容似乎是在雲服務和Web /輔助角色之間進行版本檢查,然后導致構建失敗。

更改工具版本沒有幫助。

作為背景 - 我有一個舊的雲服務引用了一個使用新的csproj樣式的4.6.2項目,如下所示:

<Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <TargetFramework>net462</TargetFramework>
   </PropertyGroup>
</Project>

HTH。 標記。

編輯:要編輯的文件是.ccproj,而不是前面所述的.cproj文件。

嚴重級代碼描述項目文件行抑制狀態錯誤項目'C:\\ path \\ to \\ project \\ src \\ Frontend \\ Frontend.csproj'目標'.NETStandard,版本= v2.0'。 它不能被針對'.NETFramework,Version = v4.0'的項目引用。

根據錯誤,您的Frontend.csproj項目以.NETStandard 2.0目標,您從一個面向.NETFramework V4.0的項目中引用了.NETStandard 2.0項目。 作為有關.NET Standard的官方文檔,您至少需要使您的項目以.NETFramework V4.6.1為目標,以引用.NETStandard 2.0項目或庫。 或者您需要選擇較低的.NET標准版本,以及遵循.NET實現支持所需的更多詳細信息。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM