Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

msbuild - Visual Studio - aspnet_merge.exe error when publishing

I've had this issue over VS 2015, 2017 and 2019, so I believe this is not specific to my setup.

aspnet_merge(0,0): Error occurred: An error occurred when merging assemblies: Object reference not set to an instance of an object

This happens after the following runs:

C:Program Files (x86)Microsoft SDKsWindowsv10.0AinNETFX 4.8 Toolsaspnet_merge.exe (project location)TempPackageBuildDirobjDebugAspnetCompileMergeTempBuildDir -o (name of assembly) -copyattrs (repository location)....TempPackageBuildDirobjDebugAssemblyInfoAssemblyInfo.dll -a -debug

I can run this exact same command on a different machine and it runs without an issue. I've been able to solve this ONCE before by explicitly setting my output directory in website.publishproj to

<PropertyGroup>
    <OutputPath>$(MSBuildProjectDirectory)....TempPackageBuildDir</OutputPath>
</PropertyGroup>

But a couple days later the issue came back. There is somethinng bad cached on my machine specifically and I don't have enough knowledge to know what it is.

Any insight would be appreciated,


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Actually, the issue is related to your project and VS environment. Please try the following steps:

1) clean all nuget caches or just delete C:Usersxxx.nugetpackages

Close, delete .vs hidden folder, bin and obj folder.

Also, delete all files under C:Users<user>AppDataLocalTempTemporary ASP.NET Files

Then, restart VS, run update-package -reinstall under Tools-->Nuget Package Manager-->Package Manager Console

If you reference any assembly dlls, please remove them first and then add them back.

Make sure that all the Merge's DLLS are not corrupted.

2) reset all vs settings under Tools-->Import and Export Settings-->Reset all Settings

3) disable any third party installed extensions to check whether there is one caused that.

4) repair vs from vs_installer

Besides, check whether you have these on web.config file. If you have, please remove them.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...