Azure App Service deployment failure, could not locate assembly just installed - asp.net

I have a NET 4.6 Web App that uses ASP.NET Core 1.1 on Azure. This Web App has a dependency on a NET 4.6 Class Library which has a dependency on Microsoft.EntityFrameworkCore (Version=1.1.1.0).
When I deploy it from Git for the first time I get messages of packages installing, like this one:
Installing Microsoft.Extensions.Primitives 1.1.0.
In fact I get three different lines that install Microsoft.Extensions.Primitives versions: 1.1.0, 1.0.1 and 1.0.0.
But in the same deployment I get over 35 errors on the Class Library project, that say that it could not locate an assembly that it just installed. One of them is Microsoft.Extensions.Primitives:
D:\Program Files (x86)\dotnet\sdk\2.0.0-preview1-005977\Microsoft.Common.CurrentVersion.targets(1964,5): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.Extensions.Primitives, Version=1.1.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. [D:\home\site\repository\ClassLibraryNet462\ClassLibraryNet462.csproj]
I see that it is trying to use NET Core 2.0.0-preview1-005977, but I don't know why. I guess that may be part of the problem.
Does anyone have any idea of how to solve it?

Related

Cannot load Microsoft.Bcl.AsyncInterfaces

I have a .NET web application that works fine at my desk but when I deploy it to the server I'm getting this error:
"Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded."
My project targets the .NET 4.6.1 framework and both machines have 4.8 installed. I already had the latest Microsoft.Bcl.AsyncInterfaces NuGet package installed so I attempted to revert to version 1.1 instead of the latest 5.0 and that didn't fix it.
I'm not sure what else to check. The Microsoft.Bcl.AsyncInterfaces.dll is in the bin folder.

devops pipeline publishing wrong assembly version (of newtonsoft.json)

I have a Blazor webassembly solution (hosted by aspnet.core webapi) which builds and runs fine locally. Server and Client reference directly newtonsoft.json.dll version 13.0.1. The server also has a reference to Microsoft.AspNetCore.Mvc.NewtonsoftJson which shows a dependency to newtonsoft.json of >=12.0.
If after compiling I search locally in the bin folders, ALL projects have version 13.0.1 but one 12.0.3 in the BlazorDebugProxy folder.
Now building,publishing and running the app via azure results in error:
Could not load file or assembly 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'. The system cannot find the file specified.
File name: 'Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
at Microsoft.AspNetCore.Mvc.MvcNewtonsoftJsonOptions..ctor()
Looking at the files in the artifacts which the build created, it is version 9.0.1 ! The only hint why this file might be the wrong version is that this is the Net Standard 1 version. However the projects all have version 5 in their csproj files, so it should not pull any framework 1 stuff and it does not locally.
I added a step to install Net 5 SDK and when starting the restore process it correctly reports that SDK version 5.0.402 is used.
In the pre Net Core world such issues where easily resolved with an assembly rebind, what do I do now ?
I finally figured it out and it's a bad behavior of the devops pipelines. The issue is that publish will internally do a build and if that is set to the whole solution, it just copies all dll's to the publish folder.
I had the build task set to just build my web project, but forgot to do the same for the publish.
Once I did set this, the correct dll was copied (what is references in the csproj file takes precedence to any other versions).
The ONLY reason one needs a separate build task is if there are other projects to build beside the one to publish, in most cases (mine) test projects.

Why does building with Microsoft.Xml.SgmlReader 1.8.18 nuget output this warning MSB2346

I'm using the Microsoft.Xml.SgmlReader nuget in several places of my .Net Core 3.1 projects.
The build output says:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targets(2123,5): warning MSB3246: Resolved file has a bad image, no metadata, or is otherwise inaccessible. Could not load file or assembly 'SgmlReader.exe' or one of its dependencies. The module was expected to contain an assembly manifest.
I'm unable to google what this really means or how I fix it. Maybe I should be using a different incarnation of the SgmlReader nuget, only this one (1.8.18) seems to be the one most up-to-date.
Edit:
No information reg. sgmlreader in fusion logs when building (or starting VS2019).
But I did notice these two in the references:
Compile Time Assemblies, SgmlReader.exe and SgmlReaderDll.dll
I can open SgmlReaderDll.dll in JustDecompile, but not SgmlReader.exe.
I also notice that the exe is part of netcoreapp3.1, but not netstandard2.0 and netstandard2.1. That does not look right to me.

After install Microsoft.Azure.NotificationHubs version 3.1, there is versioning error "System.Net.Http, Version=4.0.0.0"

I would like to implement Push Notification function so installed Microsoft.Azure.NotificationHubs in Visual Studio. However, there is version error prompt out when I launched my software in debug mode:
FileLoadException: Could not load file or assembly 'System.Net.Http, Version=4.0.0.0, Culture=neutral
You didn't mention what framework you were using. I was able to create a console .NET 4.6.1 console app and was able to debug without issue. Since you are getting a FileLoadException, I would suggest using fuslogvw to see why the binary isn't being loaded. The notification hub package may replace the System.Net.Http NETFX version with it's own version, in which case you could remove the package and add it back.

An instance of analyzer Microsoft.AspNetCore.Mvc.Analyzers.AvoidHtmlPartialAnalyzer cannot be created from C:\

I'm updating a VS2017 to use ASP.NET Core 2.1 (installing dot.net core sdk 2.1 and Microsoft.Net.Compilers 2.8.2) and I am receiving some warnings about analyzers not being able to be created after creating a new ASP.net core mvc 2.1 project.
Warnings:
Warning CS8032 An instance of analyzer Microsoft.AspNetCore.Mvc.Analyzers.AvoidHtmlPartialAnalyzer cannot be created from C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.aspnetcore.mvc.analyzers\2.1.1\analyzers\dotnet\cs\Microsoft.AspNetCore.Mvc.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Can not find the specified file.
Warning CS8032 An instance of analyzer Microsoft.EntityFrameworkCore.RawSqlStringInjectionDiagnosticAnalyzer cannot be created from C:\Program Files\dotnet\sdk\NuGetFallbackFolder\microsoft.entityframeworkcore.analyzers\2.1.1\analyzers\dotnet\cs\Microsoft.EntityFrameworkCore.Analyzers.dll : Could not load file or assembly 'Microsoft.CodeAnalysis, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. Can not find the specified file.
Any suggestions how to solve this problem?
I received the same message after installing dotnet-sdk-2.1.301.
Updating Visual Studio to the latest version (15.7.4) fixed it for me.
This is my simple solution:
Unload Project -> Reload Project -> Rebuild -> Done!
uninstall & installing Nuget of Microsoft.AspNetCore will resolve the issue

Resources