0
votes

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 SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\aspnet_merge.exe (project location)\TempPackageBuildDir\obj\Debug\AspnetCompileMerge\TempBuildDir -o (name of assembly) -copyattrs (repository location)\..\..\TempPackageBuildDir\obj\Debug\AssemblyInfo\AssemblyInfo.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,

1
Hi, any update about this issue? Please check if it helps you handle your issue. If it helps, please do not forget to accept it. And if not, please feel free to let us know:)Mr Qian

1 Answers

0
votes

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:\Users\xxx\.nuget\packages

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

Also, delete all files under C:\Users\<user>\AppData\Local\Temp\Temporary 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.