[英]Error in publishing project with MSBuild after upgrading from .Net Framework 4.7 to 4.8
I am upgrading an Asp.Net Website project to .net framework 4.8 from 4.7.我正在将一个 Asp.Net 网站项目从 4.7 升级到 .net framework 4.8。 After upgrading, the project builds successfully from visual studio and also running without any issue on local machine.
升级后,项目从visual studio成功构建,并且在本地机器上运行也没有任何问题。 When same project is published using MSBuild I am getting following error:
(AspNetMerge target) -> aspnet_merge : error occurred: An error occurred when merging assemblies: Unresolved assembly reference not allowed: System.Net.Http.
当使用 MSBuild 发布同一个项目时,我收到以下错误:
(AspNetMerge target) -> aspnet_merge : error occurred: An error occurred when merging assemblies: Unresolved assembly reference not allowed: System.Net.Http.
MsBuild command used is: msbuild.exe "D:\\Enterprise\\Enterprise.sln" /nologo /nr:false /t:Build /p:DeployOnBuild=true /p:Configuration=Release /p:PublishProfile=VSO
使用的 MsBuild 命令是:
msbuild.exe "D:\\Enterprise\\Enterprise.sln" /nologo /nr:false /t:Build /p:DeployOnBuild=true /p:Configuration=Release /p:PublishProfile=VSO
And VSO.pubxml file referenced here has following configuration:此处引用的 VSO.pubxml 文件具有以下配置:
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<publishUrl>..\..\Publish\Web</publishUrl>
<DeleteExistingFiles>False</DeleteExistingFiles>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>False</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>MergeAllOutputsToASingleAssembly</WDPMergeOption>
<UseMerge>True</UseMerge>
<SingleAssemblyName>MergedAssembly</SingleAssemblyName>
</PropertyGroup>
</Project>
You can see that <UseMerge>
is set to true
which will merge output to single assembly.您可以看到
<UseMerge>
设置为true
,这会将输出合并到单个程序集。 I tried by disabling merge altogether which fixed the issue, but I want to keep the merge option enabled as it was configured this way in the release pipeline earlier.我尝试通过完全禁用合并来解决问题,但我想保持合并选项处于启用状态,因为它在之前的发布管道中以这种方式配置。 Any help will be appreciated.
任何帮助将不胜感激。
System.Net.Http
is a library that brings so much problems to plain developers. System.Net.Http
是一个给普通开发人员带来很多问题的库。 There are many unbelievable issues with it after NuGet packages update or after targeting new .NET Framework.在 NuGet 包更新或针对新的 .NET Framework 之后,它存在许多令人难以置信的问题。
Unfortunately there is no silver bullet for resolve all these issues.不幸的是,没有解决所有这些问题的灵丹妙药。 It depends on many factors what really caused this error.
这取决于真正导致此错误的许多因素。
Most likely this is config file's <dependencyAssemblies>
section.这很可能是配置文件的
<dependencyAssemblies>
部分。 After project .NET Framework retargeting there are NuGet packages that can't be resolved using old versions of dependency assemblies.在项目 .NET Framework 重定向之后,使用旧版本的依赖程序集无法解析 NuGet 包。
Use following workflow to retarget your projects on new .NET Framework version:使用以下工作流程在新的 .NET Framework 版本上重新定位您的项目:
update-package
)update-package
)update-package -reinstall
)update-package -reinstall
)Warnings
window for some records like Found conflicts between different versions of the same dependent assembly
.Warnings
窗口中的某些记录,例如Found conflicts between different versions of the same dependent assembly
。 Double click on these records and press Yes on each popup window.Now your project correctly retargeted on new .NET Framework version with all dependencies update.现在,您的项目在所有依赖项更新的新 .NET Framework 版本上正确重定向。 And error must dissapear.
错误必须消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.