Why Microsoft.Owin.Host.SystemWeb failed to install? - asp.net-web-api

I started with an empty solution with Web API only. (no mvc)
Using NuGet to upgrade all the built-in packages to the latest stable.
Then,
Install-Package Microsoft.AspNet.WebApi.Owin
Everything's good. I get a version 5.2.2 of Microsoft.AspNet.WebApi.Owin.
After that, install Owin.Host.SystemWeb.
Install-Package Microsoft.Owin.Host.SystemWeb
It shows a Successfully installed... message. But when I look into the References of the project, the icon before Microsoft.Owin.Host.SystemWeb has a yellow triangle in its bottom.
Here is my packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.AspNet.WebApi" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.2" targetFramework="net45" />
<package id="Microsoft.Owin" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.0" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
</packages>
The solution can be built but with a Warning, not even an error:
The referenced component 'Microsoft.Owin.Host.SystemWeb' could not be found.
The question: what is the correct way to install Microsoft.Owin.Host.SystemWeb? Is there some version requirement?

Try changing
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.0" targetFramework="net45" />
to
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.0" targetFramework="net452" />

Related

uninstall nuget package that no longer exists

We had our nuget server die and the admin never made a backup. So now building on a new install won't work b/c there is nothing in the cache and it can't recreate the dependency list. I tried to force uninstall but it says that I have to restore the package before uninstalling it so it can build the dependency tree. Argh. I just want the package out of the solution so we can rebuild the site. I also tried removing it from packages.config but that didn't help.
Is there a way to manually force delete a nuget package without having access to it anymore? Otherwise I need to build a new solution from scratch and migrate the files over.
Here are the commands I tried:
uninstall-package packagename -RemoveDependencies -force
and
uninstall-package packagename -force
Here is the config file:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="custom.serialization" version="2017.3.20.142224" targetFramework="net462" />
<package id="custom.themes.flat-blue" version="2016.12.9105400" targetFramework="net452" />
<package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.Cors" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net452" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net452" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net462" />
<package id="NLog" version="4.4.5" targetFramework="net462" />
<package id="NLog.Extended" version="4.0.0.1" targetFramework="net452" />
<package id="NLog.Web" version="4.4.0" targetFramework="net452" />
</packages>
Thanks
Looks like I got it working. Here are the steps:
Close the solution.
Delete references to the package from .csproj file
Delete reference from the packages.config file.
Delete all packages from the packages folder in the root.
Open the NuGet configuration and remove the source that had the old files.
Open the solution and tell it to reload all packages. It will then pull down fresh copies of all packages except the one you deleted.
So far the solutions is building and running without any errors about the missing package!

NuGet and/or PM not working correctly all of the sudden

I have a VS 2015 Community solution with a single ASP.NET MVC C# project that has been working correctly, but all of the sudden NuGet starts behaving flaky after installing and uninstalling a package. The package name was Bogus which is a port of the Faker library that generates Fake data. The Bogus package didn't quite do all I needed, so I attempted to uninstall it using Nuget. An error occurred, but I don't remember what the error said. :S
After trying a few simple things like cleaning the solution, restarting VS, and emptying the ./packages folder and rebuilding, the problem persists.
So I shut down VS and rebooted. Then removed the contents of the AppData/Local/Nuget/cache/ and again removed all contents of the solution's packages/ folder (again). Restarted VS and performed a Build. No errors, but I still have symptoms:
Package Manager no longer recognizes the 'Add-Migration' command:
PM> add-migration Misc1
add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script
file, or operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
add-migration Misc1
~~~~~~~~~~~~~
CategoryInfo : ObjectNotFound: (add-migration:String) [], CommandNotFoundException
FullyQualifiedErrorId : CommandNotFoundException
NuGet cannot uninstall/update most of the project's installed packages. As an example, I have WebGrease v1.5.2 installed and Latest stable v1.6.0 is available. When I click the Update button I receive the following error in VS Error List pane:
Error An error occurred while retrieving package metadata for 'Newtonsoft.Json.10.0.3' from source 'C:\Users\ME\Projects\MyProject\packages'. 0
and the following error in the Output pane:
Attempting to gather dependencies information for package 'WebGrease.1.6.0' with respect to project 'MyProject', targeting '.NETFramework,Version=v4.6.1'
An error occurred while retrieving package metadata for 'Newtonsoft.Json.10.0.3' from source 'C:\Users\ME\Projects\MyProject\packages'.
========== Finished ==========
I'm really stuck at this point. I have no idea how to fix this/these problem(s) and it's cost me a day of downtime already.
One thing that's odd is that I can apparently downgrade Newtonsoft.Json to 10.0.2 and then Update it to 10.0.3 again without any errors seemingly. Can't uninstall it though and like I said, all of the other installed packages I've tried to update or uninstall generate an error - usually pointing to Newtonsoft.Json like above.
Here is packages.config:
<packages>
<package id="Antlr" version="3.4.1.9004" targetFramework="net461" />
<package id="bootstrap" version="3.0.0" targetFramework="net461" />
<package id="EntityFramework" version="6.1.3" targetFramework="net461" />
<package id="jQuery" version="1.10.2" targetFramework="net461" />
<package id="jquery.datatables" version="1.10.15" targetFramework="net461" />
<package id="jQuery.Validation" version="1.11.1" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.Agent.Intercept" version="1.2.0" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.DependencyCollector" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.JavaScript" version="0.15.0-build58334" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.PerfCounterCollector" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.Web" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.WindowsServer" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.ApplicationInsights.WindowsServer.TelemetryChannel" version="1.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.Identity.Core" version="2.2.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Identity.Owin" version="2.2.1" targetFramework="net461" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net461" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.0" targetFramework="net461" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.3" targetFramework="net461" />
<package id="Microsoft.Net.Compilers" version="1.0.0" targetFramework="net461" developmentDependency="true" />
<package id="Microsoft.Owin" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.Cookies" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.Facebook" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.Google" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.MicrosoftAccount" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.OAuth" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Security.Twitter" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net461" />
<package id="Modernizr" version="2.6.2" targetFramework="net461" />
<package id="NBuilder" version="5.0.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.3" targetFramework="net461" />
<package id="Owin" version="1.0" targetFramework="net461" />
<package id="Respond" version="1.2.0" targetFramework="net461" />
<package id="WebGrease" version="1.5.2" targetFramework="net461" />
</packages>
My problem was resolved using the simple solution provided by #Oleksandr Pshenychnyy in this SO question:
Go to VS menu Tools > Extensions and Updates > Updates and check if
there is no updates for NuGet Package Manager. Installing the latest
version solved the problem for me.
After updating NuGet everything appears to be working as expected again.

Web Api built with msbuild does not work due to Microsoft.DiaSymReader.Native assemblies

I recently started running into an issue when building my web api project using MSBuild on VSTS and I managed to reproduce it locally.
My Web Api is a standard, run of the mill api with nothing fancy added.
It has the following packages installed:
<packages>
<package id="Autofac" version="4.5.0" targetFramework="net461" />
<package id="Autofac.Owin" version="4.0.0" targetFramework="net461" />
<package id="Autofac.WebApi2" version="4.0.1" targetFramework="net461" />
<package id="Autofac.WebApi2.Owin" version="4.0.0" targetFramework="net461" />
<package id="AutoMapper" version="6.0.2" targetFramework="net461" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net461" />
<package id="EntityFramework" version="6.1.3" targetFramework="net461" />
<package id="Kentico.Libraries" version="10.0.16" targetFramework="net461" />
<package id="Kentico.Libraries.Dependencies" version="10.0.16" targetFramework="net461" />
<package id="log4net" version="2.0.8" targetFramework="net461" />
<package id="Microsoft.AspNet.Cors" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.Tracing" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net461" />
<package id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="1.0.3" targetFramework="net461" />
<package id="Microsoft.Net.Compilers" version="2.0.1" targetFramework="net461" developmentDependency="true" />
<package id="Microsoft.Owin" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Cors" version="3.1.0" targetFramework="net461" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.1.0" targetFramework="net461" />
<package id="Newtonsoft.Json" version="10.0.2" targetFramework="net461" />
<package id="Owin" version="1.0" targetFramework="net461" />
<package id="PagedList" version="1.17.0.0" targetFramework="net461" />
<package id="System.Linq.Dynamic" version="1.0.7" targetFramework="net461" />
</packages>
When I build the project locally using Visual Studio 2015, the API works as expected.
However, when I build the project using msbuild:
msbuild Portal.WebApi.csproj /p:Platform="Any CPU" /p:Configuration="Nightly" /p:VisualStudioVersion="14.0" /p:OutputPath="C:\Temp\BuildOutput"
and point my IIS to the the _PublishedWebsites\Portal.WebApi\ folder, it fails with the following error:
Could not load file or assembly
'Microsoft.DiaSymReader.Native.amd64.dll' or one of its dependencies.
The module was expected to contain an assembly manifest.
If I remove Microsoft.CodeDom.Providers.DotNetCompilerPlatform and Microsoft.Net.Compilers packages from the API project and build it again using MSBuild, the API works again as expected.
If I compare the bin folders (Visual studio build vs MSBuild), the msbuild bin folder has additional dlls and all the content of the roslyn folder is added directly to the bin folder.
Has anyone encountered such an issue?

Test explorer empty in VS2015 CE Update 3 with xUnit

I just upgraded VS2015 CE to Update 3 and realized that Test Explorer stopped working properly.
I had 3 test projects, all of them with these NuGet packages:
<package id="Castle.Core" version="3.3.3" targetFramework="net452" />
<package id="FluentAssertions" version="4.12.0" targetFramework="net452" />
<package id="MediatR" version="2.1.0" targetFramework="net452" />
<package id="Moq" version="4.5.16" targetFramework="net452" />
<package id="Newtonsoft.Json" version="6.0.4" targetFramework="net461" />
<package id="xunit" version="2.1.0" targetFramework="net452" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
<package id="xunit.assert" version="2.1.0" targetFramework="net452" />
<package id="xunit.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net452" />
<package id="xunit.runner.console" version="2.1.0" targetFramework="net452" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net452" />
everything was working fine but now after the update I cannot see the tests. Any advice?
UPDATE:
re-installed VS. Nothing changed. But I noticed that the Test console says that an exception occurred in Microsoft.VisualStudio.TestWindow.UI.TestWindowToolWindowControl
This fixed in new update.
https://msdn.microsoft.com/en-us/library/mt752379.aspx
If use not English version VS 2015 Update 3, also can help change language to English.

Packages node does not exist in packages.config

When I try to update Dapper (or any other NuGet package), Visual Studio displays:
An error occurred while writing file 'T:\ProjectPath\packages.config': Packages node does not exists in packages.config at T:\ProjectPath\packages.config.
The exact contents of said file are:
<?xml version="1.0" encoding="utf-8"?>
<packages xmlns="urn:packages">
<package id="Antlr" version="3.5.0.2" targetFramework="net45" xmlns="" />
<package id="Dapper" version="1.42" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net45" xmlns="" />
<package id="Microsoft.AspNet.WebApi" version="5.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net451" xmlns="" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net451" xmlns="" />
<package id="Moment.js" version="2.10.2" targetFramework="net451" xmlns="" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="net451" xmlns="" />
<package id="NLog" version="4.0.1" targetFramework="net451" xmlns="" />
<package id="NLog.Config" version="4.0.1" targetFramework="net451" xmlns="" />
<package id="NLog.Schema" version="4.0.1" targetFramework="net451" xmlns="" />
<package id="Oracle.ManagedDataAccess" version="12.1.021" targetFramework="net451" xmlns="" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" xmlns="" />
</packages>
A package node certainly seems to exist.
I have tried update-package dapper, update-package dapper -Reinstall, and uninstall-package dapper -Force. All yield:
PM> Update-Package dapper
Attempting to gather dependency information for multiple packages with respect to project 'ImplantRecipeDatabase', targeting '.NETFramework,Version=v4.5.1'
Attempting to resolve dependencies for multiple packages.
Resolving actions install multiple packages
Install failed. Rolling back...
Package 'Dapper 1.42' already exists in project 'ImplantRecipeDatabase'
Update-Package : An error occurred while writing file 'T:\Dropbox\WorkProjects\DataManager\ImplantRecipeDatabase\packages.config': Packages node does not exists in packages.config at T:\Dropbox\WorkProjects\DataManager\ImplantRecipeDatabase\packages.config.
At line:1 char:15
+ Update-Package <<<< dapper
+ CategoryInfo : NotSpecified: (:) [Update-Package], Exception
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PackageManagement.PowerShellCmdlets.UpdatePackageCommand
Note that the most recent version of Dapper found by NuGet as of this writing is 1.50.1
The errors aren't helpful, so I am not sure where to go from here. I have tried installing the most recent update for VS2015 Update 3 (kb3165756) and have the most recent version of NuGet (3.4.4.1321).
What should I try next?
Your packages.config file does not look correct. It has xmlns attributes where a normal packages.config would not have any. Having the root packages element in a different namespace may well be the cause of the problem. I would expect the packages.config file to look more like:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.5.0.2" targetFramework="net45" />

Resources