4
votes

I have my cloud service for which i am using azure sdk 2.9. It contains multiple csproj files. One of the projects, i want to migrate to .net version 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"

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.

2

2 Answers

10
votes

To use .NET 4.6, you need to ensure that your cloud service is using the most recent osFamily.

osFamily version 5 has the following .NET Frameworks installed:

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 
    serviceName="MyService" 
    osFamily="5" 
    osVersion="*">

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

</ServiceConfiguration>

See the complete reference documentation: Azure Guest OS releases and SDK compatibility matrix

1
votes

The following does the trick. It needs to be added at the bottom of your ccproj files.

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