Repository navigation
Description
Microsoft.Web.LibraryManager.Build 2.0.76
VS 2017 15.9.11
ASP.NET Web Form project using 4.6.1
On some machine in our office using VS 2017, we can't build our ASP.NET project that has the "auto restore" enabled for LibMan.
Some machines with VS 2017 using the same project build fine.
What seems to be odd is that our ASP.NET project references "System.Net.Http Version 4.0.0.0" yet the LibraryManager is referencing "System.Net.Http Version 4.2.0.0".
I think this is either a bad reference pointing to a file not installed on users machines or not using the GAC version of System.Net.Http.
We get the following:
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: The "Microsoft.Web.LibraryManager.Build.RestoreTask" task failed unexpectedly.
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: System.TypeInitializationException: The type initializer for 'Microsoft.Web.LibraryManager.WebRequestHandler' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Web.LibraryManager.WebRequestHandler..ctor(ProxySettings proxySettings)
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Web.LibraryManager.WebRequestHandler..cctor()
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: --- End of inner exception stack trace ---
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Web.LibraryManager.WebRequestHandler.get_Instance()
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Web.LibraryManager.Providers.Unpkg.UnpkgProvider..ctor(IHostInteraction hostInteraction)
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Web.LibraryManager.Providers.Unpkg.UnpkgProviderFactory.CreateProvider(IHostInteraction hostInteraction)
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Web.LibraryManager.Build.Dependencies.Initialize()
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Web.LibraryManager.Build.Dependencies..ctor(IHostInteraction hostInteraction, IEnumerable`1 assemblyPaths)
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Web.LibraryManager.Build.RestoreTask.Execute()
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
1>...\packages\Microsoft.Web.LibraryManager.Build.2.0.76\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at Microsoft.Build.BackEnd.TaskBuilder.d__26.MoveNext()
Activity
jimmylewis commentedon Oct 1, 2019
Can you try out the 2.0.96 version of the LibraryManager.Build package and see if it addresses the issue? It has a change that might address this (or it might not - we'll see).
senj commentedon Oct 2, 2019
I have the same issue:
On hosted VSTS Agent with Visual Studio 2019 it works. Update to 2.0.96 didn't fix it.
Now I also tested with VSTS Agent with Visual Studio 2017 and it also works there.
Guess we have to configure something on our build server, but what ..
kant2002 commentedon Jan 4, 2020
Same with VS2019 and .NET Core 3.1
kant2002 commentedon Jan 4, 2020
Actually I manage to fix that by specifying --framewok
Before:
After:
xiwan commentedon Apr 26, 2020
Hey kant2002,
I did as you guide. But the error still there.
dotnet build --configuration Release --runtime linux-x64 --framework netcoreapp3.1
PS, the env is within docker.
amoraitis commentedon May 3, 2020
Updating to the latest
Microsoft.Web.Library.Manager.Build -v 2.1.76solves that error for me.fix: ci build failed
jimmylewis commentedon Dec 13, 2021
Seems this was solved in the 2.1.76 package, so resolving the issue.
GeorgeMaharis123 commentedon Oct 3, 2022
Hi there
I am still getting these errors with VS 2017 and Microsoft.Web.LibraryManager.Build -v 2.1.175. Could it be possible this bug returned?
`C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: The "Mi
crosoft.Web.LibraryManager.Build.RestoreTask" task failed unexpectedly. [C:\Team
City\buildAgent\work\bbac78e917f81a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: System.
TypeInitializationException: The type initializer for 'Microsoft.Web.LibraryMana
ger.Cache.WebRequestHandler' threw an exception. ---> System.TypeInitializationE
xception: The type initializer for 'Microsoft.Web.LibraryManager.Configuration.S
ettings' threw an exception. ---> System.IO.FileLoadException: Could not load fi
le or assembly 'Newtonsoft.Json, Version=13.0.0.0, Culture=neutral, PublicKeyTok
en=30ad4fe6b2a6aeed'. Could not find or load a specific file. (Exception from HR
ESULT: 0x80131621) [C:\TeamCity\buildAgent\work\bbac78e917f81a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at M
icrosoft.Web.LibraryManager.Configuration.Settings..ctor() [C:\TeamCity\buildAge
nt\work\bbac78e917f81a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at M
icrosoft.Web.LibraryManager.Configuration.Settings..cctor() [C:\TeamCity\buildAg
ent\work\bbac78e917f81a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: ---
End of inner exception stack trace --- [C:\TeamCity\buildAgent\work\bbac78e917f8
1a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at M
icrosoft.Web.LibraryManager.Configuration.ProxySettings.get_Default() [C:\TeamCi
ty\buildAgent\work\bbac78e917f81a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at M
icrosoft.Web.LibraryManager.Cache.WebRequestHandler..cctor() [C:\TeamCity\buildA
gent\work\bbac78e917f81a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: ---
End of inner exception stack trace --- [C:\TeamCity\buildAgent\work\bbac78e917f8
1a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at M
icrosoft.Web.LibraryManager.Build.Contracts.Dependencies.Initialize() [C:\TeamCi
ty\buildAgent\work\bbac78e917f81a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at M
icrosoft.Web.LibraryManager.Build.RestoreTask.Execute() [C:\TeamCity\buildAgent
work\bbac78e917f81a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at M
icrosoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionH
ost.Execute() [C:\TeamCity\buildAgent\work\bbac78e917f81a30\Source...]
C:\Users\teamcitybuild.nuget\packages\microsoft.web.librarymanager.build\2.1.17
5\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error MSB4018: at M
icrosoft.Build.BackEnd.TaskBuilder.ExecuteInstantiatedTask(ITaskExecutionHost ta
skExecutionHost, TaskLoggingContext taskLoggingContext, TaskHost taskHost, ItemB
ucket bucket, TaskExecutionMode howToExecuteTask) [C:\TeamCity\buildAgent\work\b
bac78e917f81a30\Source...]`
NewToScripting commentedon Nov 3, 2022
In case anyone is facing this issue, what worked for me is deleting the .packages folder at the solution level for the nuget packages referenced. Then I restored the nuget packages and everything built again.
LibraryManager may fail on CI (likely because of multi target), possi…
kibblewhite commentedon Mar 19, 2025
2025 and still fighting with this one
To resolve it I have Downgraded Microsoft.Web.LibraryManager.Build from 3.0.67 to 2.1.175.