We have a WCF webservice that is targetting .NET framework 4.0. This WCF, uses a assembly from the same Visual Studio project that in turn uses a couple of Nuget Packages like so below:
<package id="Microsoft.AspNet.WebApi.Client" version="4.0.30506.0" targetFramework="net40" />
This Nuget package is adding two assemblies to the "System.Net.Http" and "System.Net.Http.Formatting" to the project. When this application is getting deployed using TFS Build, for some reason these two assemblies are not getting copied to the bin folder on the server. When I check the "Copy Local" flag for these two assemblies, I see that they are set to TRUE.
I have uninstalled the Nuget packages and installed it again, but doesn't seem to work.
Any suggestions as to what could be wrong?
Related
I can not use the SqlType provider due to an issue with Microsoft.Bcl.AsyncInterfaces.
I am using a minimal program with .NET 4.7.2 and F# 4.7.0.0.
My Nuget packages contain a reference to:
package id="Microsoft.Bcl.AsyncInterfaces" version="1.0.0"
targetFramework="net472"
Severity Code Description Project File Line Suppression State
Error FS3033 The type provider 'FSharp.Data.Sql.SqlTypeProvider'
reported an error: Unable to load one or more of the requested types.
Retrieve the LoaderExceptions property for more information. Details:
Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or
one of its dependencies. Das System kann die angegebene Datei nicht
finden. TestSqlProvider C:\Users\weism\source\repos\TestSqlProvider\TestSqlProvider\Program.fs 9 Active
What can I do to fix this issue?
For me, installing the Microsoft.Bcl.AsyncInterfaces (Nuget package) fixed the issue.
This error also happens when you try using Microsoft.EntityFrameworkCore v5 in a dotnet core v3.1 project.
To resolve, down-version Microsoft.EntityFrameworkCore to latest v3 version.
For .Net Core, This problem basically occur , when we use layered architecture. Just make sure the version of Microsoft.EntityFrameworkCore should be same in all project, wherever it is used.
I don't use Microsoft.Bcl.AsyncInterfaces at all in my .NET 4.8 project. Some library depends on version 1.0.0.0. I resolved the issue using a binding redirect:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Bcl.AsyncInterfaces" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
</dependentAssembly>
Microsoft.Bcl.AsyncInterfaces.dll 5 was copied to Bin after build.
I think you update package in one layer.
for me i worked in project with three layers (api, AdminTool, Data) the AdminTool Layer had a reference to Data Layer i updated all packages in AdminTool only so i had this error i update package also in data layer and api layer so the problem solved.
I hope that help you.
My Entity Framework Core just needed upgraded
TO
Make sure you have unique single version of that dll. Another step would be to add a binding redirect in the app.config as told in the above comments.
Check in your installed nuget packages---
If version of Microsoft.EntityFrameworkCore and your .net project is different then it can be a problem.
Example - If EntityFrameworkCore is at v5.1.5 or higher & your project dotnet core v3.1 project, this can be the issue.
To solve,
down-version Microsoft.EntityFrameworkCore to equal version of project such as v3 version. to down version click on tool in visual studio -->Nuget Package Manager--> Manage Nuget package for Solutions --> click on installed ---> select nuget package which you want to downgrade --> click on uninstall and then select the same nuget package and then install version 3.1.5 or relevent package.
or
Install Microsoft.Bcl.AsyncInterfaces (Nuget package)
Updating the Microsoft.Bcl.AsyncInterfaces assembly via NuGet did everything it needed to do, including adding the bindingRedirect entries in the appropriate config files.
I also did all the other hygienics. I cleaned my solution, deleted the bin and obj directory entries, and also cleaned my localhost deploy locations.
However, I still got this error. I reviewed the output (my application is a .NET 4.8 MVC Web application, so the web page showed the error log in detail), and I found that it was failing on loading SimpleInjector.
I updated SimpleInjector to the latest version via NuGet and that fixed my error.
Unfortunately, I didn't keep a copy of the error page, so I can't show you what I saw, but the bottom line is to examine the output or log in detail, see if you can find where the application is attempting to load the assembly that is failing, and update that assembly that appears to be calling the load.
I was able to fix it by removing <Private>True</Private> from csproj for Microsoft.Bcl.AsyncInterfaces. Just reinstall this NuGet package
Does Visual Studio for Mac support roslyn analyzers, especially Microsoft.CodeAnalysis.FxCopAnalyzers?
The analyzer nuget packages can be added to a project in XamarinStudio/VS2017 for mac but you need to manually edit the project files to add the ItemGroup.Analyser project items linking to the dlls. These do not install on a mac as the installers are provided as custom PowerShell install scripts in the nuget packages. Note you will need to maintain the sections manually when updating the analyzer packages or removing them.
Ex: I needed to add the following to the project file, to install the Microsoft.CodeQuality.Analyzers 2.6.0 and also reload the project file.
<ItemGroup>
<Analyzer Include="..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.0\analyzers\dotnet\cs\Microsoft.CodeQuality.Analyzers.dll" />
<Analyzer Include="..\..\packages\Microsoft.CodeQuality.Analyzers.2.6.0\analyzers\dotnet\cs\Microsoft.CodeQuality.CSharp.Analyzers.dll" />
</ItemGroup>
Once added and the project is re-build I received the CA warnings from the project, and they were displayed in the standard errors pane.
I received an ASP.NET MVC application that needs to be modified which uses System.Web.Mvc version 3.0.0.0. But when I copied the files on my dev machine, I noticed that my reference to System.Web.Mvc was broken. So my first instinct was to delete the reference and add it back, which worked fine. My application compiles. But I noticed after this change that it now references version 3.0.0.1.
Here's the problem: The client's production server has version 3.0.0.0 so when I deploy it on the server I get an error saying it cannot find 3.0.0.1.
How can I change my development machine to use System.Web.Mvc version 3.0.0.0 so that when I deploy to production, I don't get this issue.
Microsoft released Microsoft Security Bulletin MS14-059, which was a security issue so critical that they broke backward compatibility with previous versions of MVC 3 and 4. And as the issue was critical, there is no way to revert a machine back to 3.0.0.0.
However, this also makes it so a project that works with MVC 3.0.0.1 does not compile on a machine with MVC 3.0.0.0 installed. This will completely remove MVC 3.0.0.0 which was installed into the Global Assembly Cache.
MVC 3.0.0.1 on the other hand is deployed via NuGet, and you will need to add a reference to it and recompile with it in order for the patch to work (if you haven't done so already).
Best Solution
The correct solution is to install the patch on the target machine.
A Possible Alternative
However, if that machine (or your build server) is out of your control, the following hack will make your project compile on machines that both have the patch and those that don't.
Right-click on your project node in solution explorer (the one that references MVC 3), and click "Unload Project".
Right-click on it again and choose "Edit ".
Locate the reference to System.Web.Mvc and replace it with the elements below.
Save the project file.
Right-click on the project node again and click "Reload Project".
<!-- Due to the windows update MS14-059, we need this hack to ensure we can
build MVC3 both on machines that have the update and those that don't -->
<Reference Condition=" Exists('$(windir)\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_3.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll') " Include="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<Reference Condition=" !Exists('$(windir)\Microsoft.NET\assembly\GAC_MSIL\System.Web.Mvc\v4.0_3.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll') " Include="System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.AspNet.Mvc.3.0.20105.1\lib\net40\System.Web.Mvc.dll</HintPath>
</Reference>
Note that you need to have the MVC NuGet package installed for version 3.0.20105.1 for the above to work, or you will need to adjust the version number as appropriate to match the version you have.
I would love to get your help to resolve this issue. The code compiles in local box but TFS build fails for a project saying -
Entity\DbModel.Context.cs (16): The type or namespace name 'Entity' does not exist in the namespace 'System.Data' (are you missing an assembly reference?)
Entity\DbModel.Context.cs (19): The type or namespace name 'DbContext' could not be found (are you missing a using directive or an assembly reference?)
Entity\DbModel.Context.cs (26): The type or namespace name 'DbModelBuilder' could not be found (are you missing a using directive or an assembly reference?)
I am using EntityFramework 6.1.1. NuGet package for the project and Package Restore is enabled (in NuGet.targets file) -
<RestorePackages Condition=" '$(RestorePackages)' == '' ">true</RestorePackages>
I think that the package download for the EntityFramework is also failing in TFS even though the other NuGet packages for the same project are getting downloaded before the build the starts in TFS.
I am using 2 packages for this project -
<packages>
<package id="EntityFramework" version="6.1.1" targetFramework="net45" />
<package id="Newtonsoft.Json" version="6.0.6" targetFramework="net45" />
</packages>
Build Log file -
RestorePackages:
"C:\a\src\.nuget\NuGet.exe" install "C:\a\src\<project name>\packages.config" -source "" -NonInteractive -RequireConsent -solutionDir "C:\a\src\ "
Restoring NuGet packages...
To prevent NuGet from downloading packages during build, open the Visual Studio Options dialog, click on the Package Manager node and uncheck 'Allow NuGet to download missing packages'.
Installing 'Newtonsoft.Json 6.0.6'.
Successfully installed 'Newtonsoft.Json 6.0.6'.
All packages listed in packages.config are already installed.
But after Newtonsoft.Json, it didn't even download the EntityFramework Dlls.
Finally I made it work. It took a while.
At this point, 2 different options available :
Keep the NuGet.targets file and refer that NuGet.targets file from all the project (Didn’t work for me)
Explicitly call the NuGet.Exe package restore before the build
The option 1 didn’t work for me, that’s why to go ahead with the 2nd option,
I had to do:
Delete the NuGet.targets file from the .nuget folder (do not checkin that file)
Delete and do not check in the packages file
Open all the projects file in notepad and remove the reference of NuGet.targets file as mentioned in http://docs.nuget.org/docs/workflows/migrating-to-automatic-package-restore
Go to VS 2013 – Tools > Extensions and Update > VS Gallery – make sure that you have the latest NuGet
At this point, your project is ready to download Nuget packages right before any build, to test that delete the packages folder and start build, it should download all NuGet packages.
Now, for TFS Continuous build, instead of pointing the solution file directly in the build template, use a custom XML build.proj file as mentioned in the http://blogs.msdn.com/b/dotnet/archive/2013/08/27/nuget-package-restore-with-team-foundation-build.aspx.
This XML first calls NuGet.EXE restore path\.sln file, if the *.sln file is not mentioned it picks up any other solution file in the same directory
Check in the build.proj, NuGet.exe all in the root folder along with the solution file
Now, things are going smooth for me with the TFS online CI. Do not right click on the Visual Studio solution to enable the NuGet package restore - it will undo all of the above since it brings back the NuGet.targets file and direct reference to the file in each proj file.
I am new to nuget and but realized that my recent ASP.net MVC4 project already included it so I also added packages to other projects of that solution. But that was curious; now I had two versions of Json.Net
v. 4.5.6 within the ASP.net MVC project
v. 5.0.6 within any other project
So what says the nuget docs... OK then, lets update. I opened the Package Manager Console, chooses the ASP.net MVC project and typed Get-Package -updates with the result
No package updates are available from the current package source.
Which is the NuGet official package source
A look at the different packages.config showed me:
ASP.net MVC project
<package id="Newtonsoft.Json" version="4.5.6" targetFramework="net45" />
other project
<package id="Newtonsoft.Json" version="5.0.6" targetFramework="net45" />
So where am I wrong. Why didn't I see any updates available for the ASP.net MVC project
(please note that the Newtonsoft.Json package is just a example, I got the same thing for the Microsoft.AspNet.Mvc where it is not the major version that differs)
Any help appreciated.
I figured out how to get it updated. I opened the Solution Package Manager (Tools > Library Package Manager > Manage NuGet Packages for Solution)
Now I saw many duplicated entries from which I always choose the latest version, hit the manage button and added the solution that by now used the older version. NuGet now removed the the other entries and added the new one. It seems the Get-Package -updates always refer to the whole the solution (try Get-Package it will show the packages solution wide) and there I had the latest one listed.