How to Bypass Warnings When Targeting .Net 4.5.2 During Publishing

My Azure services are targeting .Net 4.5.2 and work fine in dev. However, the assembly generates a warning (s):

Warning The SurfInfoWeb project is for the .NET Framework 4.5.2. To ensure that the role is running, this version of the .NET Framework must be installed on the virtual machine for this role. You can use the run task to install the required version if it is not already installed as part of the Microsoft Azure guest OS.

I believe that these (local) warnings lead to an immediate publication failure (and these are ONLY warnings in the error list).

According to MS, 4.5.2 should be available in January 2016 (I don’t know exactly what date, but I thought I read January 12 or January 16).

I cannot suppress these warnings in the usual way because they do not have warning codes.

1) Is .Net 4.5.2 actually available on Azure

2) Is there a way to suppress warnings that don't have codes?

3) Anything else I don't think about?

I am using SDK 2.8.1. And OSVersion = "*".

+7
source share
4 answers

Is .Net 4.5.2 actually available on Azure?

Yes ..NET 4.5.2 is available in the current osVersion * osFamily 2, 3, and 4.

Is there a way to suppress warnings that don't have codes?

Cloud service projects upgraded to Azure SDK 2.9 no longer generate this warning. Projects using a previous version of the SDK (even if version 2.9 is installed) still generate this warning. To suppress this warning without upgrading the project to SDK 2.9, you can add the following snippet to your .ccproj file.

<ItemGroup> <WindowsAzureFrameworkMoniker Include=".NETFramework,Version=v4.5.2" /> </ItemGroup>

+8
source

Based on the comments provided here - https://azure.microsoft.com/en-in/documentation/articles/cloud-services-dotnet-install-dotnet/ , there is no way to suppress this warning.

enter image description here

Is .Net 4.5.2 actually available on Azure?

Today yes .. Net 4.5.2 is available on Azure. In fact, we ported our solution from .Net 4.5 to .Net 4.5.2 just a few days ago.

To use .Net 4.5.2 you cannot use the "*" for osVersion. You need to target a specific OS version. See the guest OS / Target Framework version table: https://azure.microsoft.com/en-in/documentation/articles/cloud-services-guestos-update-matrix/ .

Our solution uses osFamily 4, and based on this matrix, we ended up using WA-GUEST-OS-4.26_201511-02 osVersion. Here's what our service configuration file looks like:

 <?xml version="1.0" encoding="utf-8"?> <ServiceConfiguration serviceName="ServiceName" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="WA-GUEST-OS-4.26_201511-02" schemaVersion="2015-04.2.6"> <Role name="RoleName"> </Role> </ServiceConfiguration> 
+2
source

I get a similar version of this error, essentially a new version:

Microsoft Azure Cloud Service projects only support roles that work in the .NET Framework versions 4.0, 4.5, and 4.6. Set the Target Framework property in the project settings for the MyWorkerRole project to .NET Framework 4.0, .NET Framework 4.5 or .NET Framework 4.6.

And

The MyWorkerRole project is for the .NET Framework 4.7.2. To ensure that the role starts, this version of the .NET Framework must be installed on the virtual machine for this role. You can use the launch task to install the required version if it is not already installed as part of the Microsoft Azure guest OS. For more information, see https://go.microsoft.com/fwlink/?LinkId=309796 .

Even after following the instructions provided in the link in the message (which were useful when creating installer scripts, etc.), the warning message did not disappear. I tried all kinds of things, including groups of framework elements, all properties, etc.

I eventually included the assembly in Detailed output, figured out the .targets file it came from, and checked it. β€œI found that there is simply no built-in way to suppress it.”

HOWEVER, there is a hack that you can do - I basically copied this block from the .targets file to my .ccproj file and deleted the warning part. Essentially, I added the following to the end of my .ccproj and BADAO file! Likewise, NO MORE WARNINGS! :

 <Target Name="ValidateRoleTargetFramework" Outputs="%(RoleReference.Identity)" Condition="'@(RoleReference)' != ''"> <PropertyGroup> <_RoleTargetFramework>%(RoleReference.RoleTargetFramework)</_RoleTargetFramework> <_IsValidRoleTargetFramework>False</_IsValidRoleTargetFramework> <_IsValidRoleTargetFramework Condition="$(_RoleTargetFramework.StartsWith('v4.0')) Or $(_RoleTargetFramework.StartsWith('v4.5')) Or $(_RoleTargetFramework.StartsWith('v4.6'))">True</_IsValidRoleTargetFramework> </PropertyGroup> </Target> 

(Obviously, you should put this INSIDE <Project/> , of course.)

0
source

You need to install .net 4.5.2 on the webrole virtual machine.

Download the web installer for the .NET platform that you want to install. .NET 4.5.2 Web Installer

For web role

  • In Solution Explorer, under "Roles in the Cloud Service Project", right-click on your role and select Add> New Folder.
  • Create a folder called bin Right-click the bin folder and choose Add> Existing Item. Select the .NET installer and add it to the bin folder.
  • Define a launch task for your role ServiceDefinition.csdef <LocalResources> <LocalStorage name="NETFXInstall" sizeInMB="1024" cleanOnRoleRecycle="false" /> </LocalResources> <Startup> <Task commandLine="install.cmd" executionContext="elevated" taskType="simple"> <Environment> <Variable name="PathToNETFXInstall"> <RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/LocalResources/LocalResource[@name='NETFXInstall']/@path" /> </Variable> </Environment> </Task> </Startup>
  • Create the install.cmd file and add it to the role by right-clicking on the role and choosing Add> Existing Element.

INSTALL.CMD

`` ``

 REM Set the value of netfx to install appropriate .NET Framework. REM ***** To install .NET 4.5.2 set the variable netfx to "NDP452" ***** REM ***** To install .NET 4.6 set the variable netfx to "NDP46" ***** REM ***** To install .NET 4.6.1 set the variable netfx to "NDP461" ***** set netfx="NDP46" REM ***** Needed to correctly install .NET 4.6.1, otherwise you may see an out of disk space error ***** set TMP=%PathToNETFXInstall% set TEMP=%PathToNETFXInstall% REM ***** Setup .NET filenames and registry keys ***** if %netfx%=="NDP461" goto NDP461 if %netfx%=="NDP46" goto NDP46 set netfxinstallfile="NDP452-KB2901954-Web.exe" set netfxregkey="0x5cbf5" goto logtimestamp :NDP46 set netfxinstallfile="NDP46-KB3045560-Web.exe" set netfxregkey="0x60051" goto logtimestamp :NDP461 set netfxinstallfile="NDP461-KB3102438-Web.exe" set netfxregkey="0x6041f" :logtimestamp REM ***** Setup LogFile with timestamp ***** set timehour=%time:~0,2% set timestamp=%date:~-4,4%%date:~-10,2%%date:~-7,2%-%timehour: =0%%time:~3,2% md "%PathToNETFXInstall%\log" set startuptasklog="%PathToNETFXInstall%log\startuptasklog-%timestamp%.txt" set netfxinstallerlog="%PathToNETFXInstall%log\NetFXInstallerLog-%timestamp%" echo Logfile generated at: %startuptasklog% >> %startuptasklog% echo TMP set to: %TMP% >> %startuptasklog% echo TEMP set to: %TEMP% >> %startuptasklog% REM ***** Check if .NET is installed ***** echo Checking if .NET (%netfx%) is installed >> %startuptasklog% reg query "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP\v4\Full" /v Release | Find %netfxregkey% if %ERRORLEVEL%== 0 goto end REM ***** Installing .NET ***** echo Installing .NET: start /wait %~dp0%netfxinstallfile% /q /serialdownload /log %netfxinstallerlog% >> %startuptasklog% start /wait %~dp0%netfxinstallfile% /q /serialdownload /log %netfxinstallerlog% >> %startuptasklog% 2>>&1 :end echo install.cmd completed: %date:~-4,4%%date:~-10,2%%date:~-7,2%-%timehour: =0%%time:~3,2% >> %startuptasklog% 

`` ``

Here you can get the full detailed procedures:

Install .NET as a Cloud Service

I think you should implement this solution until Azure gets full support for .net 4.5.2, maybe not yet supported in your area. Try creating a new cloud instance in EastUS to see if net fx 4.5.2 is supported.

-1
source

All Articles