带有.NET Standard目标的Azure云服务经典版 [英] Azure Cloud Service Classic with .NET Standard target

查看:102
本文介绍了带有.NET Standard目标的Azure云服务经典版的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种方法可以运行以.netstandard2.0为目标的辅助角色的Azure Cloud Service Classic项目?

我有这样的项目,但是任何时候尝试构建它,我都会收到此错误:

严重性代码描述项目文件行抑制状态 错误项目 'C:\ path \ to \ project \ src \ Frontend \ Frontend.csproj' 定位到".NETStandard,Version = v2.0".它不能被 以目标为目标的项目 '.NETFramework,Version = v4.0'. UserDiscoveryService C:\ Program 文件\ 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/辅助角色之间进行版本检查,然后使构建失败./p>

更改工具版本无济于事.

作为背景-我有一个旧的云服务,该服务引用了使用新的csproj样式的4.6.2项目,如下所示:

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

HTH. 马克.

要编辑的文件是.ccproj,而不是前面所述的.cproj文件.

Is there a way how to run Azure Cloud Service Classic project with worker role that targets .netstandard2.0?

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'. It cannot be referenced by a project that targets '.NETFramework,Version=v4.0'. 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.

解决方案

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>

e.g.

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

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:

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

HTH. Mark.

Edit: The file to edit is the .ccproj not the .cproj file as previously stated.

这篇关于带有.NET Standard目标的Azure云服务经典版的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆