Dependence on the framework assembly "System.Runtime, Version = 4.0.10.0", which cannot be resolved in the target environment

TFS 2013 - Build: ASP.Net 4.5.1 website I get this error:

warning MSB3268: The primary reference "C:\Builds\2\MyProj\Web1_Main\bin\MyProj1.dll" could not be resolved because it has an indirect dependency on the framework assembly "System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v4.5.1". To resolve this problem, either remove the reference "C:\Builds\2\MyProj\Web1_Main\bin\MyProj1.dll" or retarget your application to a framework version which contains "System.Runtime, Version=4.0.10.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a". 

All projects and the site were 4.0 using Unity 1.0.0.0. I updated it to 4.5.2. In addition, MyProj1 in the above error refers to Unity, and I updated it to 3.5.1.

Read the following: https://unity.codeplex.com/workitem/12756 The build server already has updated 4.5.2, indicated in a workaround.

So, I downgraded to 4.5.1, but still get the error.

  • The solution is built perfectly locally using Visual studio 2013.

  • Individual class library projects are embedded in TFS, but when MyProj is added as a link to my site, this happens when it fails.

Any ideas?

Do I need any changes to web.config other than the TragetFramework attributes when updating?

+7
unity-container tfsbuild
source share
3 answers

I had to upgrade my unity to 3.5 due to the dependence of my project on some other project, and this error appeared again. This time, finally, it is fixed.

This helped me: http://devsilos.blogspot.com/2014/10/msb3268-while-targeting-aspnet-web-site.html

Decision. I copied all the files from which the complaint was built:

C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.5.2 \ Facades

For

C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.5.2

Here's an explanation from the link above if it for any reason will decrease in the future:

A deeper inspection revealed the following interesting fact: for some reason, aspnet_compiler does not take into account the .dll-s that are in the Facade directory of 4.5 assemblies (C: \ Program Files (x86) \ Assembly Links \ Microsoft \ Framework.NETFramework \ v4.5 \ Facades). It only looks under C: \ Program Files (x86) \ Reference Assemblies \ Microsoft \ Framework.NETFramework \ v4.5

As a result, everything ended since both System.Threading.Tasks and System.Runtime.dll-s are located in the Facades directory, and not inside v4.5.

Now solutions:

  • Just copy the missing .dlls from Facade into the v4.5 directory.
  • Set TargetFrameworkMoniker to 4.5.1 in the .sln file. The exact syntax is as follows: TargetFrameworkMoniker = ".NETFramework, version% 3Dv4.5.1".

What happens in this case is that the aspnet_compiler does not recognize the exact version of the required structure and use the GAC wherever it is. If 4.5 is the highest version installed on the build machine, I believe that it should work.

+1
source share

Actually sorry I don't think assemblyBinding would help. This seems like a known bug . He was not allowed. Using Unity 3.5, you can target .NET 4.5.1, but not 4.5.2. So one option would be to reassign to .NET 4.5.1 and see if the problem goes away, if that is the option.

ps You can also try the .NET Framework 4.5.2 Developer Pack . But some mentioned that this did not work.

+2
source share

We recently encountered a similar problem with a site that was upgraded to the target .NET 4.5, and first implemented the solution in gbs answer .

In our case, we had several warnings following this pattern:

<project name> .metaproj: warning MSB3268: the primary link "<project link> DLL" cannot be resolved because it has an indirect dependency on the structure assembly "System.Runtime, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a "which cannot be resolved in the current target environment. ".NETFramework, Version = v4.5." To fix this problem, delete the link "<project reference> .dll" or reconfigure the application to the framework version that contains "System.Runtime, Version = 4.0.0.0, Culture = neutral, PublicKeyToken = b03f5f7f11d50a3a".

Then we found that if you create a new website targeting 4.5.x (File> New> Web Site ...) and select the ASP.NET Empty Web Site template, the Microsoft.Net.Compilers package is included. Adding this package to our site resolved the problem without having to touch support assemblies.

From the original two solutions, copying the files made the build successful, but it presented maintenance problems, and changing TargetFrameworkMoniker (to 4.5.3, not 4.5.1) caused another build error and was a fragile solution.

0
source share

All Articles