'Multiple assemblies with equivalent identity have been imported' - Azure Deployment [closed] - c#

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I'm getting a 'Multiple assemblies with equivalent identity have been imported' error when deploying to Azure.
Here's the deployment log
Command: "D:\home\site\deployments\tools\deploy.cmd"
Handling .NET Web Application deployment.
MSBuild auto-detection: using msbuild version '14.0' from 'D:\Program Files (x86)\MSBuild\14.0\bin'.
All packages listed in packages.config are already installed.
Filanthropy.Model -> D:\home\site\repository\Filanthropy.Model\bin\Release\Filanthropy.Model.dll
CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'D:\home\site\repository\packages\System.Runtime.InteropServices.4.1.0\lib\net462\System.Runtime.InteropServices.dll' and 'D:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.InteropServices.dll'. Remove one of the duplicate references. [D:\home\site\repository\Filanthropy.Core\Filanthropy.Core.csproj]
CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'D:\home\site\repository\packages\System.Runtime.Extensions.4.1.0\lib\net462\System.Runtime.Extensions.dll' and 'D:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.Extensions.dll'. Remove one of the duplicate references. [D:\home\site\repository\Filanthropy.Core\Filanthropy.Core.csproj]
CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'D:\home\site\repository\packages\System.Runtime.4.1.0\lib\net462\System.Runtime.dll' and 'D:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.dll'. Remove one of the duplicate references. [D:\home\site\repository\Filanthropy.Core\Filanthropy.Core.csproj]
CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'D:\home\site\repository\packages\System.Reflection.4.1.0\lib\net462\System.Reflection.dll' and 'D:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Reflection.dll'. Remove one of the duplicate references. [D:\home\site\repository\Filanthropy.Core\Filanthropy.Core.csproj]
CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'D:\home\site\repository\packages\System.IO.4.1.0\lib\net462\System.IO.dll' and 'D:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.IO.dll'. Remove one of the duplicate references. [D:\home\site\repository\Filanthropy.Core\Filanthropy.Core.csproj]
CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'D:\home\site\repository\packages\System.Diagnostics.Tracing.4.3.0-preview1-24530-04\lib\net462\System.Diagnostics.Tracing.dll' and 'D:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Diagnostics.Tracing.dll'. Remove one of the duplicate references. [D:\home\site\repository\Filanthropy.Core\Filanthropy.Core.csproj]
Failed exitCode=1, command="D:\Program Files (x86)\MSBuild\14.0\Bin\MSBuild.exe" "D:\home\site\repository\Filanthropy.Web\Filanthropy.Web.csproj" /nologo /verbosity:m /t:Build /t:pipelinePreDeployCopyAllFilesToOneFolder /p:_PackageTempDir="D:\local\Temp\8d3fe5a038ffaf0";AutoParameterizationWebConfigConnectionStrings=false;Configuration=Release;UseSharedCompilation=false /p:SolutionDir="D:\home\site\repository\.\\"
An error has occurred during web site deployment.
\r\nD:\Program Files (x86)\SiteExtensions\Kudu\58.51019.2480\bin\Scripts\starter.cmd "D:\home\site\deployments\tools\deploy.cmd"
i've been through the relevant csproj file, and can confirm that there are no duplicates in it. This doesm't happen on my local machine, only when deploying to azure.

Related

System references in bamboo

I have installed one nuget package in my project which has dependency on some of the system dlls like system.IO/system.Reflection etc. So when I install that nuget package everything works fine in my local. However, when I push my code to bamboo (build server) I start getting multiple assemblies error:
26-Mar-2019 05:30:23 CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'E:\agt01\ENS-EB577-BEQI\Bin\Packages\System.Xml.ReaderWriter.4.3.0\lib\net46\System.Xml.ReaderWriter.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Xml.ReaderWriter.dll'. Remove one of the duplicate references. [E:\agt01\ENS-EB577-BEQI\myProject\myProject.csproj]
26-Mar-2019 05:30:23 CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'E:\agt01\ENS-EB577-BEQI\Bin\Packages\System.Runtime.InteropServices.4.3.0\lib\net462\System.Runtime.InteropServices.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Runtime.InteropServices.dll'. Remove one of the duplicate references. [E:\agt01\ENS-EB577-BEQI\myProject\myProject.csproj]
26-Mar-2019 05:30:23 CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'E:\agt01\ENS-EB577-BEQI\Bin\Packages\System.Reflection.4.3.0\lib\net462\System.Reflection.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.Reflection.dll'. Remove one of the duplicate references. [E:\agt01\ENS-EB577-BEQI\myProject\myProject.csproj]
26-Mar-2019 05:30:23 CSC : error CS1703: Multiple assemblies with equivalent identity have been imported: 'E:\agt01\ENS-EB577-BEQI\Bin\Packages\System.IO.4.3.0\lib\net462\System.IO.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\System.IO.dll'. Remove one of the duplicate references. [E:\agt01\myProject-EB577-BEQI\myProject\myProject.csproj]
26-Mar-2019 05:30:23
26-Mar-2019 05:30:23 617 Warning(s)
26-Mar-2019 05:30:23 4 Error(s)
So basically bamboo is trying to pick those system dlls from C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2\Facades\
So to work that around, I have to make sure I remove these references from my csproj as nuget packages and push to bamboo in order to get a successful build but when testing in my local I have to add them as nuget packages to get things to work.
Has any one faced such issue before?
For the specific errors you included, it looks as though you have duplicate imports of the assemblies within your .csproj file. I would open up the myProject.csproj and pick either the ones in Bin\Packages or the System ones installed as part of the .Net Framework install.
I personally would go with the System installed ones that were put there as part of the framework install. If you are having issues finding those on the Bamboo agent, make sure that .NET Framework 4.6.2 is installed on the build agent in the specified location (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.2)

what does ImplicitlyExpandDesignTimeFacades do exactly in csporj (C# - Visual Studio 2015)

I added a package from Nuget that targeted .NET Standard 2.0
After that, I got build error below:
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.ComponentModel.EventBasedAsync.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.ComponentModel.EventBasedAsync.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Xml.XDocument.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Xml.XDocument.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Threading.Timer.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Threading.Timer.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Threading.Tasks.Parallel.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Threading.Tasks.Parallel.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Threading.Tasks.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Threading.Tasks.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Threading.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Threading.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Text.Encoding.Extensions.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Text.Encoding.Extensions.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Text.Encoding.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Text.Encoding.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Security.Principal.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Security.Principal.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Runtime.Serialization.Json.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Runtime.Serialization.Json.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Runtime.Numerics.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Runtime.Numerics.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Runtime.Handles.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Runtime.Handles.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Resources.ResourceManager.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Resources.ResourceManager.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Reflection.Primitives.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Reflection.Primitives.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Reflection.Extensions.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Reflection.Extensions.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.ObjectModel.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.ObjectModel.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Net.Requests.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Net.Requests.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Net.Primitives.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Net.Primitives.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Linq.Queryable.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Linq.Queryable.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Linq.Parallel.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Linq.Parallel.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Globalization.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Globalization.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Dynamic.Runtime.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Dynamic.Runtime.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Diagnostics.Tools.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Diagnostics.Tools.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Diagnostics.Debug.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Diagnostics.Debug.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Diagnostics.Contracts.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Diagnostics.Contracts.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.ComponentModel.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.ComponentModel.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Collections.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Collections.dll'. Remove one of the duplicate references.
Error CS1703 Multiple assemblies with equivalent identity have been imported: 'C:\Program Files (x86)\MSBuild\Microsoft\Microsoft.NET.Build.Extensions\net461\ref\System.Collections.Concurrent.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6.1\Facades\System.Collections.Concurrent.dll'. Remove one of the duplicate references.
I found a solution and fixed it by adding <ImplicitlyExpandDesignTimeFacades> false </ImplicitlyExpandDesignTimeFacades> to .csproj file
My question is what is ImplicitlyExpandDesignTimeFacades and what does it do?
why is visual studio looking for libraries in "Reference Assemblies" folder? (isn't this for the design time?)
why are they put same libraries in another location ("Reference Assemblies")?
shouldn't visual studio load .Net libraries from "Windows" directory?
how is it possible to have different versions in different locations?
Sorry for a lot number of questions. I think they are not separate.

ASP.NET web site builds locally, but throws MSB3268 on the build server

I added a project to my web site solution. Everything built fine locally and on the build server.
I added a line in web code to call a method in the new project. Everything built and worked fine locally, but it broke the build on the build server.
I got a pile of errors going something like this:
warning MSB3268: The primary reference "C:...\ProjectName.dll" could not be resolved because it has an indirect dependency on the framework assembly "Assembly.Name (e.g. System.Runtime)", Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.5". To resolve this problem, either remove the reference "C:...\ProjectName.dll" or retarget your application to a framework version which contains "System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a".
After all the warnings, the build failed with an error indicating the namespace ProjectName could not be found. Makes sense considering the project's dependencies couldn't be resolved.
At first I wondered if there was an issue with targeting the wrong framework. But there was a mix of 4.0 and 4.5 projects referenced by the 4.5 website. This was the first one that had failed.
The only difference between this and the other projects was that it referenced third-party DLLs. So apparently their dependencies are the ones that couldn't be resolved.
This post held the key: http://devsilos.blogspot.com/2014/10/msb3268-while-targeting-aspnet-web-site.html
The author suggests:
aspnet_compiler for some reason does not take into account the .dll-s that reside under the Facade directory of 4.5 assemblies (C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5\Facades).
It looks only under
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5
My extrapolation on that idea is that maybe the compiler doesn't take into account DDLs in the Facades directory if they're referenced by a third-party DLL rather than directly from your project.
The solution, as suggested by the author, was to find the DLLs matching assemblies mentioned in the MSB3268 warnings and copy them from Facades to its parent directory.
I think my problem/solution differed from the blog's in that it had nothing to do with the .NET Framework version targeted. It had only to do with whether the build server's compiler looked in the right places to resolve third-party DLLs' dependencies.
The problem caused about ten hours of frustration. I hope this helps someone else avoid that!

System.Collections.Immutable reference to System.Runtime and FxCop/metrics

On Windows 7 with .NET 4.5.2 installed, I create a new ClassLibrary project targetting .NET 4.5.2.
I want to calculate the code metrics for that assembly by launching the metrics.exe that is shipped with FxCop with Visual Studio 2013 located in c:\Program Files (x86)\Microsoft Visual Studio 12.0\Team Tools\Static Analysis Tools\FxCop\.
Everything works fine.
I then nuget System.Collections.Immutable v1.1.37.
I can see in the references that only System.Collections.Immutable is referenced since the other dependencies (System.Runtime, System.Collections, System.Diagnotics.Debug etc.) are found (I suppose in c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\)
I create a dummy method that creates a dummy ImmutableArray var foo = new List<int>().ToImmutableArray();
Everything compiles and works just fine.
I relaunch the metrics computation.
I have the following error:
metrics.exe /f:c:\dev\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll /o:toto.xml
error : CA0055 : Could not load file:
'c:\dev\ClassLibrary1\ClassLibrary1\bin\Debug\ClassLibrary1.dll'.
If I perform the same command on the System.Immutable.Collections assembly, I have the following error:
Calculating metrics for file 'c:\dev\ClassLibrary1\ClassLibrary1\bin\Debug\System.Collections.Immutable.dll'.
Could not locate the framework assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
Now, if I copy the System.Runtime file located in c:\Windows\Microsoft.NET\Framework\v4.0.30319\ in the output directory, calculating the code metrics on ClassLibrary1.dll works fine. But if I copy the version that is in c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.2\Facades\, if fails again.
When debugging another library using Immutable in a web application, I can see the following in the "Loaded modules":
System.Runtime.dll C:\windows\Microsoft.Net\assembly\GAC_MSIL\System.Runtime\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.Runtime.dll Yes No Skipped loading symbols. 544 4.06.1055.0 06/11/2015 03:49 000007FED10D0000-000007FED10D9000 [15760] w3wp.exe [4] /LM/W3SVC/2/ROOT/WebSite-2-131026947404276669
All of this makes me think that System.Collections.Immutable uses the version of System.Runtime that is in c:\Windows\Microsoft.NET\Framework\v4.0.30319\
So I thought, "let's add an explicit reference to that assembly." If I do, I got the following compilation error:
error CS1703: Multiple assemblies with equivalent identity have been imported: 'c:\Windows\Microsoft.NET\Framework\v4.0.30319\System.Runtime.dll' and 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETFramework\v4.5.2\Facades\System.Runtime.dll'. Remove one of the duplicate references.
There something somewhere that is wrong and I can't pinpoint it.
I worked around the error by using the /ignoreinvalidtargets for metrics.exe.
Does anyone have a club about the real error?
(I also tried targetting .NET Framework 4 and adding references to all the dependant assemblies from c:\Windows\Microsoft.NET\Framework\v4.0.30319\ with CopyLocal = true. It works, despite the following warning:
Some NuGet packages were installed using a target framework different from the current target framework and may need to be reinstalled. Visit http://docs.nuget.org/docs/workflows/reinstalling-packages for more information. Packages affected: System.Collections, System.Collections.Immutable, System.Diagnostics.Debug, System.Globalization, System.Linq, System.Resources.ResourceManager, System.Runtime, System.Runtime.Extensions, System.Threading
)
Thanks.

MSBuild can no longer find dependencies after upgrading from 4.0 to 4.5?

We have a .Net 3.5 application that is built using some scripts that call msbuild.exe
Recently all our machines started automatically updating from .Net 4.0 to .Net 4.5 as part of a company-wide policty, and our build scripts started failing.
The errors given is that they cannot find a referenced assembly, like this :
error CS0012: The type 'System.Drawing.Image' is defined in an assembly that is not referenced.
You must add a reference to assembly 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
It looks like in every case, we try to build project A that has a reference to project B, and project B has a reference to library X, and get an error that project A needs a reference to library X.
A temporary workaround is to uninstall 4.5, uninstall 4.0, then re-install 4.0, however this is time consuming and not practical in an environment where updates are often silent and automatic.
I've tried using the following msbuild switches already, with no luck
/toolsversion:3.5 - Exception about Func being undefined
/toolsversion:4.0 - Does not work because 4.5 replaced 4.0 tools
/p:TargetFrameworkVersion="v3.5" - Same error
/p:VisualStudioVersion=11.0 - Same error
*` in the csproj file - Already exists, and same error
The .csproj files already has <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> specified in every single csproj file in my solution, and ToolsVersion="4.0".
I have also tried changing the TargetFrameworkVersion to 4.0, and that does not work either.
I found some notes online about Microsoft changing the flag OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration from false to true during the 4.0 to 4.5 update, however manually setting that flag in the csproj files also does not fix the issue.
<OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration>
false
</OnlyReferenceAndBuildProjectsEnabledInSolutionConfiguration>
Why is msbuild failing to find these child assemblies after upgrading from 4.0 to 4.5, and how can I fix it?
Update
I've finally figured out the source of the problem, but I have no idea how this could be happening.
ProjectA has a class which inherits from an abstract class in ProjectB, and one of the properties of ProejctB.BaseClass is of type System.Drawing.Image.
namespace ProjectA
{
public class SomeClass : BaseClass { }
}
namespace ProjectB
{
public abstract class BaseClass
{
public System.Drawing.Image GetImage() { };
}
}
From everything I've read online, and from creating a test project of my own, this means that ProjectA needs a reference to System.Drawing.Image in order to build.
But for whatever reason, this restriction does not seem to matter for our project when buliding with msbuild 4.0 or in VS 2010. It's perfectly happy to build ProjectA without a reference to System.Drawing.Image.
Even after updating to .Net 4.5, I can still build ProjectA successfully from Visual Studio 2010 without adding a reference to System.Drawing.Image, however building using msbuild now (correctly?) fails. I also get the reference errors when building in VS 2012 Express, so whatever is allowing this to occur has apparently been fixed in newer versions of VS.
For now, I have gone through all 148 projects in our solution and fixed all the references, however I want to leave this question open to try and get an answer on why I am able to build ProjectA using msbuild 4.0 or Visual Studio 2010 without a reference to System.Drawing.Image.
I have already determined that I can't easily reproduce the behavior in a test project, so my best guess is its either some configuration, some part of the build scripts, or it's a bug that existed back when the .sln or .csproj files got created and no longer exists with newly created projects.
Based on Hans' comment, it sounds like something changed in the internal C# compiler between version 4 and version 5 to fix the bug that was allowing us to build ProjectA without proper references.
This doesn't have anything to do with MSBuild, what changed is that you are using a different C# compiler. Version 5 instead 4. I've seen cursory evidence in other questions that is is more aggressive about wanting to resolve indirect type references. Nothing to nail to the wall, everybody just fixes this with the obvious solution.
When viewing the msbuild.exe log, I can see it comes down to a call to csc.exe, which contains the exact same /reference list, however fails with 4.5.
Building ProjectA with 4.0
Task "Csc"
c:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE /reference:C:\Path\bin\Release\ProjectB.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug:pdbonly /filealign:512 /keyfile:ProjectA.snk /optimize+ /out:obj\Release\ProjectA.dll /target:library Properties\AssemblyInfo.cs SomeFile.cs Properties\VersionInfo.cs
Microsoft (R) Visual C# 2010 Compiler version 4.0.30319.1
Copyright (C) Microsoft Corporation. All rights reserved.
Done executing task "Csc".
Building ProjectA with 4.5
Task "Csc" (TaskId:5812)
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /errorreport:prompt /warn:4 /define:TRACE /highentropyva- /reference:C:\Path\bin\Release\ProjectB.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Web.Services.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug:pdbonly /filealign:512 /keyfile:ProjectA.snk /optimize+ /out:obj\Release\ProjectA.dll /target:library /utf8output Properties\AssemblyInfo.cs SomeFile.cs Properties\VersionInfo.cs (TaskId:5812)
Microsoft (R) Visual C# Compiler version 4.0.30319.18408 (TaskId:5812)
(TaskId:5812)
for Microsoft (R) .NET Framework 4.5 (TaskId:5812)
Copyright (C) Microsoft Corporation. All rights reserved. (TaskId:5812)
(TaskId:5812)
SomeFile.cs(32,18): error CS0012: The type 'System.Drawing.Image' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. [C:\Path\ProjectA.csproj]
c:\Path\bin\Release\ProjectB.dll: (Location of symbol related to previous error) (TaskId:5812)
The command exited with code 1. (TaskId:5812)
Done executing task "Csc" -- FAILED. (TaskId:5812)
I was hoping someone here would be able to explain what that was, and how I could reproduce this "bug" with 4.0, however it doesn't look like this question is an easy one to answer.
If I had to guess, I'm going to say that all the references that it can no longer locate are version 2.0.0.0. We had a similar issue here recently where we had to update the references to be for 4.0.0.0 versions of System.* and mscorlib and similar references.
If you cannot replace the references and BindingRedirects aren't an option, try adding v2.0.0.0 manually to your bin folder.
Lastly, you can make your build output verbose to see where it's looking for these references, it might guide you to find a solution.
Perhaps when it updates its not updating your Runtime Settings Schema, specifically the <probing> Element that tells .Net what paths to search for assemblies:
Eg.
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin;bin2\subbin;bin3"/>
</assemblyBinding>
</runtime>
</configuration>
See: http://msdn.microsoft.com/en-us/library/microsoft.build.tasks.assignprojectconfiguration.onlyreferenceandbuildprojectsenabledinsolutionconfiguration%28v=vs.121%29.aspx
Rachel, any chance references on your System.Drawing on projects are set to SpecificVersion = true after the upgrade?
Also, are you using any precompiled resx files in your library projects?
Try right-clicking the .resx file and choosing 'Run Custom Tool' again to redo the references.
And for last of my attempts to help you, you could try using the useLegacyV2RuntimeActivationPolicy="true" on your main project configuration and try to use the legacy System.Drawing library.

Categories

Resources