简体   繁体   English

azure 云服务支持.net 4.6 或更高版本

[英]Supporting .net version 4.6 or higher in azure cloud service

I have my cloud service for which i am using azure sdk 2.9.我有我使用 azure sdk 2.9 的云服务。 It contains multiple csproj files.它包含多个 csproj 文件。 One of the projects, i want to migrate to .net version 4.6其中一个项目,我想迁移到 .net 4.6 版

When i upgrade the project and try to deploy the service, i get the error as "Microsoft Azure Cloud Service projects only support roles that run on .NET Framework versions 4.0 and 4.5"当我升级项目并尝试部署服务时,我收到错误消息“Microsoft Azure 云服务项目仅支持在 .NET Framework 4.0 和 4.5 版上运行的角色”

I read on on internet that if the service uses Azure sdk 2.9, this error should not come but i am unable to find any help online, hence i am posting this issue here.我在互联网上读到,如果该服务使用 Azure sdk 2.9,则不应出现此错误,但我无法在线找到任何帮助,因此我在此处发布此问题。

To use .NET 4.6, you need to ensure that your cloud service is using the most recent osFamily .要使用 .NET 4.6,您需要确保您的云服务使用最新的osFamily

osFamily version 5 has the following .NET Frameworks installed: osFamily版本5安装了以下 .NET Frameworks:

4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2

You can set this in your ServiceConfiguration :您可以在ServiceConfiguration进行设置:

<ServiceConfiguration 
    serviceName="MyService" 
    osFamily="5" 
    osVersion="*">

    <!-- your role definitions in here -->

</ServiceConfiguration>

See the complete reference documentation: Azure Guest OS releases and SDK compatibility matrix请参阅完整的参考文档: Azure 来宾操作系统版本和 SDK 兼容性矩阵

The following does the trick.以下是诀窍。 It needs to be added at the bottom of your ccproj files.它需要添加到 ccproj 文件的底部。

<ItemGroup>
    <WindowsAzureFrameworkMoniker Include=".NETFramework,Version=v4.8" />
</ItemGroup>
<Target Name="ValidateRoleTargetFramework" Outputs="%(RoleReference.Identity)" Condition="'@(RoleReference)' != ''">
    <PropertyGroup>
        <_RoleTargetFramework>%(RoleReference.RoleTargetFramework)</_RoleTargetFramework>
        <_IsValidRoleTargetFramework>True</_IsValidRoleTargetFramework>
    </PropertyGroup>
</Target>

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

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