NuGet Pack - The 'targetFramework' attribute is not declared - c#

I'm trying to convert a project in my solution to a nuget package. I threw in a .nuspec that was edited from another nuget package I've created, and all seems to be pointing to the correct stuff. My project clearly has a "target Framework" set under properties to 4.6.2, yet when I run my package to pack I'm getting the 'targetFramework' attribute not declared error. I'll post the logs here if you think it'll help. (Also worth mentioning that I'm doing this through TeamCity's nuget CLI build step)
Here's my sanitized nuspec:
<?xml version="1.0"?>
<package >
<metadata>
<id>PROJECTNAME.WebUI</id>
<version>$version$</version>
<title>PROJECTNAME.WebUI</title>
<authors>COMPANYNAME</authors>
<owners>COMPANYNAME</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>PROJECTNAME.WebUI</description>
<releaseNotes></releaseNotes>
<copyright>Copyright 2018, COMPANYNAME</copyright>
<dependencies>
<dependency id="AntiXSS" version="4.2.1" targetFramework="net462" />
<dependency id="Aspose.Cells" version="8.7.0" targetFramework="net462" />
<dependency id="Aspose.Email" version="6.2.0" targetFramework="net462" />
<dependency id="Aspose.Pdf" version="11.3.0" targetFramework="net462" />
<dependency id="Aspose.Words" version="16.1.0" targetFramework="net462" />
<dependency id="CuteEditor" version="6.7.1.1" targetFramework="net462" />
<dependency id="EO.Pdf" version="15.3.1.0" targetFramework="net462" />
</dependencies>
</metadata>
<files>
</files>
</package>

From the documentation about dependencies.
You can specify multiple targets with this syntax
<?xml version="1.0"?>
<package >
<metadata>
<id>PROJECTNAME.WebUI</id>
<version>$version$</version>
<title>PROJECTNAME.WebUI</title>
<authors>COMPANYNAME</authors>
<owners>COMPANYNAME</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>PROJECTNAME.WebUI</description>
<releaseNotes></releaseNotes>
<copyright>Copyright 2018, COMPANYNAME</copyright>
<dependencies>
<group targetFramework="net462">
<dependency id="AntiXSS" version="4.2.1" />
<dependency id="Aspose.Cells" version="8.7.0" />
<dependency id="Aspose.Email" version="6.2.0" />
<dependency id="Aspose.Pdf" version="11.3.0" />
<dependency id="Aspose.Words" version="16.1.0" />
<dependency id="CuteEditor" version="6.7.1.1" />
<dependency id="EO.Pdf" version="15.3.1.0" />
</group>
</dependencies>
</metadata>
<files>
</files>
</package>
Or, if it is a simple library with no differences among targets, then do not make any reference to the target framework.
<?xml version="1.0"?>
<package >
<metadata>
<id>PROJECTNAME.WebUI</id>
<version>$version$</version>
<title>PROJECTNAME.WebUI</title>
<authors>COMPANYNAME</authors>
<owners>COMPANYNAME</owners>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>PROJECTNAME.WebUI</description>
<releaseNotes></releaseNotes>
<copyright>Copyright 2018, COMPANYNAME</copyright>
<dependencies>
<dependency id="AntiXSS" version="4.2.1" />
<dependency id="Aspose.Cells" version="8.7.0" />
<dependency id="Aspose.Email" version="6.2.0" />
<dependency id="Aspose.Pdf" version="11.3.0" />
<dependency id="Aspose.Words" version="16.1.0" />
<dependency id="CuteEditor" version="6.7.1.1" />
<dependency id="EO.Pdf" version="15.3.1.0" />
</dependencies>
</metadata>
<files>
</files>
</package>

Related

Files (.CS) not appearing in custom nuget package as editable, adding the files with <files> causes duplicates

perhaps I am going in the wrong direction with this, but any advice would be appreciated. I am trying to develop a small nuget package which can be installed into new .NET Framework Web Apps (MVC) so that new projects can start quicker, quickly adding features such as SSO, Areas, and business logic etc.
This then needs to be extendable so once the package is installed, the routes, areas, and auth can all be built upon.
The package works fine, it can be installed into a new project and all the auth, styling and routes work fine. The problem is these installed features appear to be hidden away within the .dll or the bin of the package, and I'm seemingly not able to edit them.
I tried adding some extra details in the csproj, and/or the .nuspec manifest, to manually pushing the files into the projects file structure. Unfortunately this just seems to create duplicates on top of the files encased in the nugets .dll and causes build errors.
Is it possible to actually have editable .cs files in nuget packages which can be accessed by the user, or am I overstepping the goal of this package?
See below my .nuspec manifest.
<?xml version="1.0" encoding="utf-8"?>
<package >
<metadata>
<id>$id$</id>
<version>1.1</version>
<title>$title$</title>
<authors>$author$</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<license type="expression">MIT</license>
<!-- <icon>icon.png</icon> -->
<description>$description$</description>
<releaseNotes>Initial Release</releaseNotes>
<copyright>$copyright$</copyright>
<tags>x</tags>
<dependencies>
<group targetFramework=".NETFramework4.8">
<dependency id="Antlr" version="3.5.0.2" />
<dependency id="bootstrap" version="5.1.3" />
<dependency id="jQuery" version="3.6.0" />
<dependency id="jQuery.Validation" version="1.19.4" />
<dependency id="Microsoft.AspNet.Mvc" version="5.2.9" />
<dependency id="Microsoft.AspNet.Razor" version="3.2.9" />
<dependency id="Microsoft.AspNet.Web.Optimization" version="1.1.3" />
<dependency id="Microsoft.AspNet.WebPages" version="3.2.9" />
<dependency id="Microsoft.CodeDom.Providers.DotNetCompilerPlatform" version="3.6.0" />
<dependency id="Microsoft.IdentityModel.Abstractions" version="6.20.0" />
<dependency id="Microsoft.IdentityModel.JsonWebTokens" version="6.20.0" />
<dependency id="Microsoft.IdentityModel.Logging" version="6.20.0" />
<dependency id="Microsoft.IdentityModel.Protocols" version="6.20.0" />
<dependency id="Microsoft.IdentityModel.Protocols.OpenIdConnect" version="6.20.0" />
<dependency id="Microsoft.IdentityModel.Tokens" version="6.20.0" />
<dependency id="Microsoft.jQuery.Unobtrusive.Validation" version="3.2.12" />
<dependency id="Microsoft.Owin" version="4.2.2" />
<dependency id="Microsoft.Owin.Host.SystemWeb" version="4.2.2" />
<dependency id="Microsoft.Owin.Security" version="4.2.2" />
<dependency id="Microsoft.Owin.Security.Cookies" version="4.2.2" />
<dependency id="Microsoft.Owin.Security.OpenIdConnect" version="4.2.2" />
<dependency id="Microsoft.Web.Infrastructure" version="2.0.0" />
<dependency id="Modernizr" version="2.8.3" />
<dependency id="Newtonsoft.Json" version="13.0.1" />
<dependency id="Owin" version="1.0" />
<dependency id="System.IdentityModel.Tokens.Jwt" version="6.20.0" />
<dependency id="WebGrease" version="1.6.0" />
</group>
</dependencies>
</metadata>
<files>
<file src="Areas\Admin\AdminAreaRegistration.cs" target="content\Areas\Admin\" />
<file src="App_Start\Startup.Auth.cs" target="content\App_Start\" />
<file src="Areas\Admin\Controllers\AdmiNController.cs" target="content\Areas\Admin\Controllers\" />
</files>
</package>
I don't think it is possible because NuGets are already COMPILED CODE.
also, NuGet's goal is to package reusable code and really not make them editable.
What you are probably looking for is Source Generators .NET SDK

NpgSQL 4.1.3.1 I can connect to PostgreSQL 12 but not PostgreSQL11

I can use C# and NpgSQL to connect to a PostgreSQL 12 instance. However when I use the same exact code to connect to a PostgreSQL 11 instance I get an exception. Object reference not set to an instance of an object. This is from line 1708 of NpgsqlConnector.cs (from disassembly).
The packages in my solution are as follows:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Bcl.AsyncInterfaces" version="1.1.1" targetFramework="net471" />
<package id="Npgsql" version="4.1.3.1" targetFramework="net471" />
<package id="System.Buffers" version="4.5.0" targetFramework="net471" />
<package id="System.Memory" version="4.5.3" targetFramework="net471" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net471" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="net471" />
<package id="System.Text.Encodings.Web" version="4.6.0" targetFramework="net471" />
<package id="System.Text.Json" version="4.6.0" targetFramework="net471" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="net471" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net471" />
<package id="Teradata.Client.Provider" version="16.20.9" targetFramework="net471" />
</packages>
Unfortunately it was mostly my lack of experience with PostgreSQL.
I was lacking a pg_hba.conf entry for the machine I was trying to connect from. The error message was NOT very helpful...

NuGet.Core: This package has been deprecated as it is legacy and no longer maintained

I upgraded my C# project from .Net 4.6.2 to 4.8. I also took the time to update all my NuGet packages.
There is one package, NuGet.Core, which I believe Microsoft installed. This package now has a warning:
NuGet.Core
Installed: 2.14.0 / Version: 2.14.0 (Deprecated)
This package has been deprecated as it is legacy and no longer maintained.
If I attempt to uninstall the package, I see that other Microsoft packages depend on it, which makes sense ans the Description for this package states: NuGet.Core is the core framework assembly for NuGet that the rest of NuGet builds upon.
So what does Microsoft want from me? I cannot uninstall the package, nor do I get a directive as to what to uninstall that replaces it.
I did a Google search and nothing comes up. I guess the problem is still to new.
Environment
Visual Studio 16.3.1 (Visual Studio Enterprise 2019)
Target framework: .Net Framework 4.8
Update:
My project is a C# WinForms project.
I have 59 or so NuGet packages. Most of the packages appear to be Microsoft in origin. I installed a few of them, true.
Error Unable to uninstall 'NuGet.Core.2.14.0' because 'Signature.Core.1.0.1' depends on it.
Contents of package.config:
<package id="AlphaFS" version="2.2.6" targetFramework="net48" />
<package id="AlphaVSS" version="1.4.0" targetFramework="net48" />
<package id="Auth0.OidcClient.Core" version="2.4.2" targetFramework="net48" />
<package id="Auth0.OidcClient.WinForms" version="2.4.2" targetFramework="net48" />
<package id="BouncyCastle" version="1.8.5" targetFramework="net48" />
<package id="EntityFramework" version="6.3.0" targetFramework="net48" />
<package id="Google.Protobuf" version="3.9.2" targetFramework="net48" />
<package id="IdentityModel" version="4.0.0" targetFramework="net48" />
<package id="IdentityModel.OidcClient" version="2.9.0" targetFramework="net48" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="net48" />
<package id="Microsoft.Bcl.Build" version="1.0.21" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Configuration.Binder" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Options" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.Extensions.Primitives" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.Graph" version="1.17.0" targetFramework="net48" />
<package id="Microsoft.Graph.Core" version="1.17.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.JsonWebTokens" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Logging" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.IdentityModel.Tokens" version="5.5.0" targetFramework="net48" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="net48" />
<package id="Microsoft.NETCore.Platforms" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.PowerShell.5.ReferenceAssemblies" version="1.1.0" targetFramework="net48" />
<package id="Microsoft.Web.Xdt" version="3.0.0" targetFramework="net48" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="net48" />
<package id="Mono.Cecil" version="0.11.0" targetFramework="net48" />
<package id="MySql.Data" version="8.0.17" targetFramework="net48" />
<package id="NETStandard.Library" version="2.0.3" targetFramework="net48" />
<package id="Newtonsoft.Json" version="12.0.2" targetFramework="net48" />
<package id="NuGet.Core" version="2.14.0" targetFramework="net48" />
<package id="ObjectListView.Official" version="2.9.1" targetFramework="net48" />
<package id="Signature.Core" version="1.0.1.0" targetFramework="net48" />
<package id="SSH.NET" version="2016.1.0" targetFramework="net48" />
<package id="StrongNamer" version="0.0.8" targetFramework="net48" />
<package id="System.AppContext" version="4.3.0" targetFramework="net48" />
<package id="System.Buffers" version="4.5.0" targetFramework="net48" />
<package id="System.Collections" version="4.3.0" targetFramework="net48" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="net48" />
<package id="System.ComponentModel" version="4.3.0" targetFramework="net48" />
<package id="System.ComponentModel.Annotations" version="4.6.0" targetFramework="net48" />
<package id="System.Console" version="4.3.1" targetFramework="net48" />
<package id="System.Data.SQLite" version="1.0.111.0" targetFramework="net48" />
<package id="System.Data.SQLite.Core" version="1.0.111.0" targetFramework="net48" />
<package id="System.Data.SQLite.EF6" version="1.0.111.0" targetFramework="net48" />
<package id="System.Data.SQLite.Linq" version="1.0.111.0" targetFramework="net48" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.DiagnosticSource" version="4.6.0" targetFramework="net48" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="net48" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="net48" />
<package id="System.Globalization" version="4.3.0" targetFramework="net48" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="net48" />
<package id="System.IdentityModel.Tokens.Jwt" version="5.5.0" targetFramework="net48" />
<package id="System.IO" version="4.3.0" targetFramework="net48" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="net48" />
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="net48" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="net48" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Linq" version="4.3.0" targetFramework="net48" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="net48" />
<package id="System.Memory" version="4.5.3" targetFramework="net48" />
<package id="System.Net.Http" version="4.3.4" targetFramework="net48" />
<package id="System.Net.Primitives" version="4.3.1" targetFramework="net48" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="net48" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="net48" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="net48" />
<package id="System.Reflection" version="4.3.0" targetFramework="net48" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="net48" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime" version="4.3.1" targetFramework="net48" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.6.0" targetFramework="net48" />
<package id="System.Runtime.Extensions" version="4.3.1" targetFramework="net48" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="net48" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.1" targetFramework="net48" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="net48" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.2" targetFramework="net48" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="net48" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="net48" />
<package id="System.Text.Encodings.Web" version="4.6.0" targetFramework="net48" />
<package id="System.Text.RegularExpressions" version="4.3.1" targetFramework="net48" />
<package id="System.Threading" version="4.3.0" targetFramework="net48" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="net48" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="net48" />
<package id="System.ValueTuple" version="4.5.0" targetFramework="net48" />
<package id="System.Xml.ReaderWriter" version="4.3.1" targetFramework="net48" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="net48" />
My guess is that Visual Studio 20XX installed a lot of them, when I selected the WinForms project. Another option is adding controls, whatever the situation most of the items are the .Net Framework.
Okay, more information.
Signature.Core
Core functions to allow signing a Nuget package after building.
It is possible that I added this package years ago now that I think about it to allow for signing. I might have run into a signed package on installation. Too much time elapsed since I first created this project. I can remove Signature.Core and see if that depends on something further up the food chain.
Thoughts?
NuGet.Core: This package has been deprecated as it is legacy and no
longer maintained
When the author of one package will no longer maintain the package, he can deprecate it. As for Nuget.Core package, it's once part of NuGet client v2 APIs. Now they have been replaced by NuGet client v3 and later APIs. See additional details here.
According to your details, you should use Signature.Core package for signing several years ago, since this package depends on these three packages:
When we try to install the Signature.Core package, package manager will install these three packages first if they do not exist in current project. So maybe the reason why you have Nuget.Core installed is because you installed the Signature.Core package, whose author is Maarten Balliauw.
Error Unable to uninstall 'NuGet.Core.2.14.0' because
'Signature.Core.1.0.1' depends on it.
In this situation, it's expected behavior that you get this message. Cause the Signature.Core is installed, and it depends on Nuget.Core package. Apart from Nuget.Core package, you'll get similar message when you try to uninstall Mono.Cecli before uninstalling the Signature.Core like:
So if you don't need the Signature.Core package any more, you can feel free to uninstall it,as well as those three packages(Nuget.Core,Mono.Cecil,Microsoft.Web.Xdt), just take care if other packages depend on them.

Xamarin.Android nuget package references System.Web

General
I am developing a mobile application using the Xamarin framework. The project is quite large and uses several nuget packages.
Environment
Xamarin.Forms v2.5.0.122203
Xamarin for VS2015 4.9.0.753
Visual Studio Professional 2015
Mono.Android v6
Target framework Android 6.0 (Marshmallow)
Minimum Android version 4.4.87 (API 20 - Kit Kat)
Suddenly after installing some packages (I can't remember which one) I get the following error
Exception while loading assemblies: System.IO.FileNotFoundException:
Could not load assembly 'System.Web, Version=4.0.0.0'
It seems like a package uses System.Web.
So I thought I could just add the reference from here
C:\Program Files (x86)\Reference
Assemblies\Microsoft\Framework.NETFramework\vX.X
The project is compiling and starting. But instantly after starting the app on my tablet, it crashes.
Debug output
04-24 10:30:02.924 D/Mono (26732): Assembly Loader probing
location: 'System.Web'.
04-24 10:30:02.924 F/monodroid-assembly(26732): Could not load
assembly 'System.Web' during startup registration.
04-24 10:30:02.924 F/monodroid-assembly(26732): This might be due to
an invalid debug installation.
04-24 10:30:02.924 F/monodroid-assembly(26732): A common cause is to
'adb install' the app directly instead of doing from the IDE.
I don't assume anyone has a clear solution for this. Is there a tool which tells me, what package references System.Web?
Thanks in advance!
packages.config
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Acr.UserDialogs" version="6.3.8" targetFramework="portable46-net451+win81" />
<package id="ExifLib.PCL" version="1.0.1" targetFramework="portable46-net451+win81" />
<package id="FAKE" version="4.35.0" targetFramework="portable46-net451+win81" />
<package id="FluentValidation" version="6.2.1.0" targetFramework="portable46-net451+win81" />
<package id="HWebbuilder.Enum" version="0.2.3" targetFramework="portable46-net451+win81" />
<package id="HWebbuilder.HCirsSmart.Shared" version="0.1.5" targetFramework="portable46-net451+win81" />
<package id="HWebbuilder.Interface" version="0.1.12" targetFramework="portable46-net451+win81" />
<package id="Microsoft.Bcl" version="1.1.10" targetFramework="portable45-net45+win8+wp8+wpa81" requireReinstallation="true" />
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="Microsoft.CSharp" version="4.0.1" targetFramework="portable46-net451+win81" />
<package id="Microsoft.Net.Http" version="2.2.29" targetFramework="portable46-net451+win81" />
<package id="NControl" version="0.9.1.0" targetFramework="portable46-net451+win81" />
<package id="NControl.Controls" version="0.9.3.3" targetFramework="portable46-net451+win81" />
<package id="Newtonsoft.Json" version="6.0.8" targetFramework="portable46-net451+win81" />
<package id="NGraphics" version="0.4.0" targetFramework="portable46-net451+win81" />
<package id="Rg.Plugins.Popup" version="1.0.4" targetFramework="portable46-net451+win81" />
<package id="Splat" version="1.6.2" targetFramework="portable46-net451+win81" />
<package id="SQLite.Net.Core-PCL" version="3.1.1" targetFramework="portable46-net451+win81" />
<package id="sqlite-net-pcl" version="1.1.2" targetFramework="portable46-net451+win81" />
<package id="SQLitePCL.bundle_green" version="0.9.2" targetFramework="portable45-net45+win8+wp8+wpa81" />
<package id="SQLitePCL.raw" version="0.9.2" targetFramework="portable45-net45+win8+wp8+wpa81" requireReinstallation="true" />
<package id="System.Collections" version="4.3.0" targetFramework="portable46-net451+win81" />
<package id="System.Data.Common" version="4.3.0" targetFramework="portable46-net451+win81" />
<package id="System.Dynamic.Runtime" version="4.0.11" targetFramework="portable46-net451+win81" />
<package id="System.Globalization" version="4.3.0" targetFramework="portable46-net451+win81" />
<package id="System.IO" version="4.3.0" targetFramework="portable46-net451+win81" />
<package id="System.Linq" version="4.1.0" targetFramework="portable46-net451+win81" />
<package id="System.Reflection" version="4.1.0" targetFramework="portable46-net451+win81" />
<package id="System.Reflection.Extensions" version="4.0.1" targetFramework="portable46-net451+win81" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="portable46-net451+win81" />
<package id="System.Runtime" version="4.3.0" targetFramework="portable46-net451+win81" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="portable46-net451+win81" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="portable46-net451+win81" />
<package id="System.Threading" version="4.0.11" targetFramework="portable46-net451+win81" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="portable46-net451+win81" />
<package id="Xamarin.Forms" version="2.5.0.122203" targetFramework="portable46-net451+win81" />
<package id="XLabs.Core" version="2.0.5782" targetFramework="portable46-net451+win81" />
<package id="XLabs.Forms" version="2.0.5782" targetFramework="portable46-net451+win81" />
<package id="XLabs.IoC" version="2.0.5782" targetFramework="portable46-net451+win81" />
<package id="XLabs.Platform" version="2.0.5782" targetFramework="portable46-net451+win81" />
<package id="XLabs.Serialization" version="2.0.5782" targetFramework="portable46-net451+win81" />
<package id="ZXing.Net.Mobile" version="2.4.1" targetFramework="portable46-net451+win81" />
<package id="ZXing.Net.Mobile.Forms" version="2.4.1" targetFramework="portable46-net451+win81" />
</packages>
The 'HWebbuilder'-packages are custom private packages. They do not contain a reference to System.Web. I doublechecked it.
To anyone having similar problems, use ILSpy to analyze your assemblies! Great tool!

Could not load file or assembly Microsoft.Owin.Security.OAuth, Version=2.0.0.0

I have a MVC project with OAuth authentication, every time I try to debug the project i get a FileLoadException upon configuring the IAppBuilder. I have installed version 3.0.1 of Microsoft.Owin.Security.Oauth using the PMC but I guess somewhere still lies a reference to an older version of the package because...
This is the exception:
This is where it is thrown:
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app); //Exception is thrown here
}
}
This is my packages.config:
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Antlr" version="3.4.1.9004" targetFramework="net45" />
<package id="CommonServiceLocator" version="1.3" targetFramework="net45" />
<package id="EntityFramework" version="6.0.0" targetFramework="net45" />
<package id="jQuery" version="1.10.2" targetFramework="net45" />
<package id="jQuery.Validation" version="1.11.1" targetFramework="net45" />
<package id="log4net" version="2.0.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Owin" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Mvc" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.Web.Optimization" version="1.1.1" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Client" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Core" version="5.2.3" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.HelpPage" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.Owin" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebApi.WebHost" version="5.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net45" />
<package id="Microsoft.jQuery.Unobtrusive.Validation" version="3.0.0" targetFramework="net45" />
<package id="Microsoft.Owin" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Host.SystemWeb" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Cookies" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security.Google" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Owin.Security.OAuth" version="3.0.1" targetFramework="net45" />
<package id="Microsoft.Web.Infrastructure" version="1.0.0.0" targetFramework="net45" />
<package id="Modernizr" version="2.6.2" targetFramework="net45" />
<package id="Newtonsoft.Json" version="7.0.1" targetFramework="net45" />
<package id="Owin" version="1.0" targetFramework="net45" />
<package id="Unity" version="3.5.1404.0" targetFramework="net45" />
<package id="WebGrease" version="1.6.0" targetFramework="net45" />
</packages>
I tried adding binding redirect as such:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Owin.Security.OAuth" PublicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
</dependentAssembly>
Can´t understand why this doesn´t work, does Visual Studio make a difference between 3.0.1 and 3.0.1.0?
I tried removing obj and bin folders, cleaning projects and rebuilding them.
I tried deleting all nuget packages and restoring them.
I tried reinstalling all Owin packages.
I´ve used Agent Ransack to search my entire source directory for any file containing Microsoft.Owin.Security.OAuth but found no references to version 2.0.0.0 or any other version besides the correct 3.0.1.0.
I´m stuck, any ideas?
Ok, so just in case anyone else ends up with this problem;
The problem was that the Microsoft.AspNet.Identity.Owin package is depending on Microsoft.Owin.Security.OAuth and there was a mismatch in version.
<package id="Microsoft.AspNet.Identity.Core" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.EntityFramework" version="1.0.0" targetFramework="net45" />
<package id="Microsoft.AspNet.Identity.Owin" version="1.0.0" targetFramework="net45" />
Apparently, even though Microsoft.AspNet.Identity.Owin requires >= v2.0 of Microsoft.Owin.Security.OAuth, having v3+ of Microsoft.Owin.Security.OAuth will break the compatibility (major version inconsistency).
After I had updated Microsoft.AspNet.Identity.Owin package and its adjacent family members Microsoft.AspNet.Identity.EntityFramework and Microsoft.AspNet.Identity.Core I removed all packages, bin and obj folders and rebuilt solution. Voila!
A tip to the VS2013+ Ultimate user is to use the NuGet Package Visualizer when exploring package dependencies.
Check your references. Remove the Microsoft.Owin.Security.OAuth from everywhere, then restore all nuget packages.

Categories

Resources