简体   繁体   English

Azure Cloud Service Classic with .NET Standard目标

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

Is there a way how to run Azure Cloud Service Classic project with worker role that targets .netstandard2.0? 有没有办法如何使用针对.netstandard2.0的辅助角色运行Azure Cloud Service Classic项目?

I have such project, but any time I try to build it I receive this error: 我有这样的项目,但任何时候我尝试构建它我收到此错误:

Severity Code Description Project File Line Suppression State Error Project 'C:\\path\\to\\project\\src\\Frontend\\Frontend.csproj' targets '.NETStandard,Version=v2.0'. 严重级代码描述项目文件行抑制状态错误项目'C:\\ path \\ to \\ project \\ src \\ Frontend \\ Frontend.csproj'目标'.NETStandard,版本= v2.0'。 It cannot be referenced by a project that targets '.NETFramework,Version=v4.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 UserDiscoveryService C:\\ Program Files \\ dotnet \\ sdk \\ 2.0.2 \\ Sdks \\ Microsoft.NET.Sdk \\ build \\ Microsoft.NET.Sdk.Common.targets 87

I tried to set target framework inside ccproj, but it didn't helped me. 我试图在ccproj中设置目标框架,但它没有帮助我。

Just in case anyone else encounters this, I got past this error by adding this line to the Project/PropertyGroup section of the cloud service .ccproj file: <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion> 为了防止其他人遇到这个问题,我通过将此行添加到云服务.ccproj文件的Project / PropertyGroup部分来解决此错误: <TargetFrameworkVersion>v4.6.2</TargetFrameworkVersion>

eg 例如

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

By default the cloud services project does not specify the framework (it doesn't need to) but something in MSBuild appears to be doing a version check between the cloud service and the web / worker roles and then failing the build. 默认情况下,云服务项目不指定框架(它不需要),但MSBuild中的某些内容似乎是在云服务和Web /辅助角色之间进行版本检查,然后导致构建失败。

Changing the tools version did not help. 更改工具版本没有帮助。

As background - I have an old cloud service that references a 4.6.2 project that uses the new csproj style like this: 作为背景 - 我有一个旧的云服务引用了一个使用新的csproj样式的4.6.2项目,如下所示:

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

HTH. HTH。 Mark. 标记。

Edit: The file to edit is the .ccproj not the .cproj file as previously stated. 编辑:要编辑的文件是.ccproj,而不是前面所述的.cproj文件。

Severity Code Description Project File Line Suppression State Error Project 'C:\\path\\to\\project\\src\\Frontend\\Frontend.csproj' targets '.NETStandard,Version=v2.0'. 严重级代码描述项目文件行抑制状态错误项目'C:\\ path \\ to \\ project \\ src \\ Frontend \\ Frontend.csproj'目标'.NETStandard,版本= v2.0'。 It cannot be referenced by a project that targets '.NETFramework,Version=v4.0'. 它不能被针对'.NETFramework,Version = v4.0'的项目引用。

Based on the error, your Frontend.csproj project targets .NETStandard 2.0 and you referenced the .NETStandard 2.0 project from a project targets .NETFramework V4.0. 根据错误,您的Frontend.csproj项目以.NETStandard 2.0目标,您从一个面向.NETFramework V4.0的项目中引用了.NETStandard 2.0项目。 As the official documentation about .NET Standard , you need to at least make your project targets .NETFramework V4.6.1 for referencing the .NETStandard 2.0 project or library. 作为有关.NET Standard的官方文档,您至少需要使您的项目以.NETFramework V4.6.1为目标,以引用.NETStandard 2.0项目或库。 Or you need to choose the lower .NET Standard version, more details you need to follow .NET implementation support . 或者您需要选择较低的.NET标准版本,以及遵循.NET实现支持所需的更多详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM