简体   繁体   中英

Azure Cloud Service Project Not Compatible With Worker Role Project in new .csproj format

We are attempting to upgrade our existing Azure Worker Role project to target .NET 4.7.2, and to re-target all dependent projects in our solution to .NET Standard 2.0 - this is an intermediate step as we work to eliminate the Worker Role project entirely and migrate to .NET Core 3.0 Worker Service hosted in Docker containers.

All project files ( .csproj ) in our solution have been converted to the "new" format and we've eliminated packages.config and all is well. Almost.

The one remaining hurdle we have is trying to build our Azure Cloud Service project (the .ccproj file that produces the packaged worker role files for Azure). Attempting to build the Cloud Service project results in an error at line 1653 of Microsoft.Common.CurrentVersion.targets :

Project foo targets net472 . It cannot be referenced by a project that targets .NETFramework, Version=v4.0 .

We are pretty much stumped at this point. I've not found any references to this specific error that are related to the worker role project in the new .csproj format.

I tried leaving the Worker Role project in the "old" project file format and targeting it to .NET 4.7.2 and the Azure Cloud Service project builds just fine -- except that NuGet package references from the dependent .NET Standard projects in our solution are not properly resolved and the NuGet package DLLs are not propagated to the build output folder - from what I've read, that's because the "new" project format method of referencing NuGet packages is not compatible with the old packages.config format. I've had to resort to manually adding one NuGet package at a time to the Worker Role project as new missing dependencies turn up at runtime. Obviously not a good solution when we have close to 100 NuGet packages in use in our project.

Found from the following: Azure Cloud Service Classic with .NET Standard target

Adding the following line in the.ccproj file fixed it for me:

    <TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion> 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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