MSBuild 4.0 introduces dependency on 4.0 framework - visual-studio-2010

We've recently upgraded all our .NET projects from VS2005 to VS2010. As a part of this move, we've upgraded from compiling with MSBuild 3.5 to MSBuild 4.0. All our compiles are from the command-line, with the following command (or similar):
msbuild.exe /Target:Publish <solution> /ToolsVersion:2.0
This seemed to work without a problem. However, we've just noticed that we now have a dependency on .NET 4.0 within our ClickOnce application manifest. Under 3.5, we would have the following:
<dependency>
<dependentAssembly dependencyType="preRequisite" allowDelayedBinding="true">
<assemblyIdentity name="Microsoft.Windows.CommonLanguageRuntime" version="2.0.50727.0" />
</dependentAssembly>
</dependency>
Under 4.0, this version number has increased to 4.0.30319.0. If we publish from within VS2010 itself, everything appears to work correctly (version number is 2.0 as before).
As a last resort, we can modify the .manifest, resign, update/resign the deployment manifest, but that sounds like alot of steps. Is there a setting somewhere to control this? Has anyone encountered the above problem before?
Cheers,
Daniel B.

Leave the ToolsVersion at 4.0 (it just affect the MSBuild version used, and you want the latest), what you need to change is TargetFrameworkVersion: set it to 3.5 or 2.0 (both use the same version with CLR, 3.5 brings additional assemblies). Thus, call msbuild as follows:
msbuild.exe /Target:Publish <solution> /p:TargetFrameworkVersion=3.5

Related

Visual studio project to MonoDevelop

Is there a way to transfer a Visual Studio project to the MonoDevelop environment?
at FAQ - MonoDevelop it is said that:
MonoDevelop can open, manipulate and save MSBuild-based projects directly in mopst cases. In fact, since MonoDevelop 2.0 the default project format has been VS2008-style MSBuild projects, but VS2005 and VS1010 formats are also handled.
But when I try to open my (ASP.NET Web Application) .vbproj in MonoDevelop, I get:
Load operation failed. Project does not support framework
'.NETFramework,Version=v4.0'.
Should I alter project settings, allowing different .NETFramework version or do I have to use some 3rd party softwares to translate my projects config files?
EDIT:(Resolved)
If your project is not that big yet, create a new project in your Microsoft Visual Studio(MVS) with .NET Framework 3.5 and then it will be possible to open it with MonoDevelop, else edit your projects Debug/Release config files and delete everything that has "4.0" information about this project, plus .vbproj file in are previous doesn't work and do the same, search for 4.0 information. (Applicable for framework 4.0)
OR
Change your project settings as it is described here:
http://msdn.microsoft.com/en-us/library/bb398202.aspx
What version of MonoDevelop are you using? MonoDevelop 2.8 can open .NET 4.0 projects (I believe 2.6 can as well). In fact, in 2.8 .NET 4.0 is the default for all new projects.
MonoDevelop's VB.NET addin still doesn't support .NET 4.0. It would work for C# projects.
Using a text editor, change your *.vbproj file to add the following line:
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
to the first PropertyGroup, e.g.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
...
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
.net framework 4.0 not yet completly implemented in mono
but includes most of the features
try to download latest version of mono and retry:)
I had the same problem in version 3.0 of MonoDevelop.
VBNET development have changed the runtime. NET
Tools> Options> Runtimes. NET
I have marked as default MONO 2.x

My Visual Studio is missing Microsoft.VisualStudio.QualityTools.UnitTestFramework

I configured now a new computer. Installed VS 2010 and all necessary component, got my running project on that new computer..
Compiling the project shows me that VS 2010 cannot find the reference "Microsoft.VisualStudio.QualityTools.UnitTestFramework".
This assembly is located in
Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies
But VS is not able to find it.
The used project is OK. It can be compiled on my old machine!
Edit:
The error while compiling:
error CS0234: The type or namespace name 'VisualStudio' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve this reference. Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors.
Upgrade of some 2003 code for us was resolved through the following:
Removing the existing broken reference
Updating the project from .Net 3.5 to .Net 4 (not the client version)
Adding the new one from VS2010 OR VS2012
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
The existing "USING" statement worked without change.
"using Microsoft.VisualStudio.TestTools.UnitTesting;"
I had the same problem.
Old machine:
Windows XP, 32 bit
VS 2010 (32 bit)
New machine:
Windows 7, 64 bit
VS 2010 (32 bit)
I solved it by simply deleting the reference to Microsoft...UnitTestFramework, and adding the new one, which was here:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
I did not need to change the target .NET framework version.
Check that your project is not marked for X64 platform in a mixed solution configuration (right click the solution -> Configuration Manager option). After changing the platform for the test project from X64 to Any CPU the assemblies were recognized and it worked.
Forget to mark this as solved:
What I did:
Uninstalled VS 2008 and VS2010 including all updates - Installed VS2008 full, VS2010 full Now it works! The cause is still unknown!
Staggering: 7 years on, still an issue
The solution that worked for me (Visual Studio 2017, Pro) was to delete the reference from the list (see image below) and then re-add it.
No Solution, just some hints:
// using Microsoft.VisualStudio.QualityTools.UnitTestFramework
// Path: %ProgramFiles(x86)%\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
You also need to check the versions. There are two out by now (10.1.0.0 and 10.0.0.0) A wrong will result in such an error.#
All versions of the unity-framework can be found at Codeplex. unity.codeplaex.com
Compile against the .DotNet4 Framework 4 instead of the .DotNet4 Framework 4 Client Profile might also solve the problem.
I was getting the same problem, but found that in the references it was set as GAC, so I removed this and put it in the BIN folder. When it was on one server it was fine but that was because it was registered on that machine and not the other
I believe your problem is that you have a project that was created on a machine with VS2010 SP1 installed and you are running on a machine with VS2010 (no SP). I recently had to change machines and my IS department installed an image on the new machine with VS2010, just like I asked.
When I pulled my code down out of source control, all of a sudden I couldn't run the unit tests because
"Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework"
Then I remembered that I had installed SP1 on my old machine. So I installed VS2010 SP1 on the new machine and magically the problem went away.
So try downloading and installing SP1
I had the same problem, too. It was caused by an config file automatically generated for the unit test dll, I didn't notice.
The app.cfg - file content was:
<?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Microsoft.VisualStudio.QualityTools.UnitTestFramework" publicKeyToken="B03F5F7F11D50A3A" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-10.1.0.0" newVersion="10.1.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
I have just removed that app.cfg file and everything worked fine without any other changes again.
I had same problem.
You need to change target framework of your project from ".Net Framework 4 Client Profile" to ".Net Framework 4"
It worked for me.
I had the same problem in an old project targeting DotNet Framework 2; updating it to DotNet Framework 3.5 solved it for me.

Using VS 2010, can I reference a project created in VS 2005?

Here's a puzzler - something that doesn't work that I assumed would (no surprise there).
We have a library project that is referenced in a few other desktop app projects. The library project is written in VS 2005 (.NET 2.0).
My problem is that some of our apps still live in VS 2005 for the time being (for various reason). I can't seem to reference this library project in VS 2010 without it demanding that I upgrade it to .NET 4, which if I do, then breaks my ability to include it as a reference in my VS 2005 projects.
This type of thing fries my brain. Is there any way I can make this work?
Hmm, that doesn't make a lot of sense. You don't reference a 'library project', you reference the DLL that it produces. Project + Add Reference, Browse tab. There's no known problem with that, within a 95% accuracy guess, mixed mode assemblies have a few hairs.
If you actually try to load a vs2005 project into a vs2010 solution, then yes, it's going to try to convert the project file. And that turns vs2005 catatonic, it doesn't have the time machine to guess what a vs2010 project looks like. Just making a copy of the project directory solves that problem.
Can you change the .NET version back to 3.5 or 2.0 in VS.NET 2010 after it revises the project version to .NET 4.0?
Use a file reference to the built dll, rather than a project reference.
You may also find you need to add an extra bit of compatible-framework info to your manifest file to tell .net to allow your .exe to use .net 4 and .net 2 assemblies alongside each other - if it's not there you'll just get an error on startup. (Sorry, I can't remember the exact details and I'm not at my work machine right now to be able to find them - but if you have problems at runtime, the error message should lead you to the exact solution you need)
Correction: I was thinking of this 'useLegacy' startup setting, which you may need to add to your app.config if you want to use a mixture of .net 2.0 and .net 4.0 assemblies in your application:
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
On option, that is a complete PITA, but should work is:
Create a new project file in 2010 that includes everything the 2005 project file has. Just call it MyProject2010.csproj or whatever.
Then, add this project to your 2010 solution.

What is the impact of upgrading MSBuild to VS2010 for projects targeting .NET Framework 2.0 and 3.5?

I’m working on the build process for a VS 2010 solution and some projects within it target the .NET framework 4.0. As far as I know, to have this type of solution built by TFS 2008 we will have to change the version of the MSBuild.exe file used by the build agent – modifying the TFSBuildService.exe.config file, pointing MSBuildPath entry accordingly.
Do you know if this will have any impact to existing project builds that target the 2.0 and 3.5 framework? Are you aware of any known issues with this type of set up?
We made such upgrade from VS2008 to VS2010 without the TFS migration (so it's still in 2008 version). Only problem we had was with build machine (cause we have only one) so we had to configure SideBySide builds. We had projects in VS2008 solution with MSBUILD scripts, some of them were migrated to VS2010.
Here's the solution http://www.codeproject.com/KB/architecture/SideBySideTfsBuild.aspx
After changing we didn't experience any problems, yet:)

NUnit isn't running Visual Studio 2010 code

I'm trying to load a Visual Studio 2010 beta dll into the NUnit GUI. I get a popup error.
This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. You may be attempting to load an assembly build with a later version of the CLR than the version under which NUnit is currently running.
How do I force an executable to run under .NET 4?
I've downloaded the NUnit 2.5 source and opened the VS2008 solution in the VS2010 beta. Once the conversion finished I opened all the projects and changed the target framework setting for all the projects to ".NET Framework 4.0". I then built the solution without any errors. I can now use the NUnit GUI app to run tests built for .NET 4.0. I've not done exhaustive testing of this build so there may be problems, but for my purposes it works fine.
Update: It is not necessary to rebuild NUnit. I discovered that if you add the following to the relevant NUnit config file you can run a test dll built for .NET 4.0.
Under <configuration> add:
<startup>
<supportedRuntime version="v4.0.30319" />
</startup>
and under <runtime> add:
<loadFromRemoteSources enabled="true" />
With .NET 4 being released, I used
<supportedRuntime version="v4.0.30319" />
in the NUnit 2.5.4 exe.config instead of requiredRuntime, and the loadFromRemoteResources tag as shown above and all worked well. Thanks!
You don't have to modify any file
just open this file and everything will work just fine
C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-x86.exe
In NUnit 2.5.5 you can specify in the command line the option /framework=net-4.0 and it is compatible with the new assemblies generated with the release of the latest VS2010.
The proposed solution worked great for getting NUnit to run. Unfortunately, when I then got to my code coverage step, NCover started giving me:
Profiled process terminated. Profiler
connection not established.
The best solution I found to this was to just use the "-x86" version of NUnit with NCover:
NCover.Console.exe
nunit-console-x86.exe --additional params--
Works now.
To find your .net 4 version from the Visual [C# 2010 Express, or which ever] go to the Visual application's "About" under the menu's Help item. It should show up as the version under the Microsoft .NET Framework line on the top right hand side of the window.
I ran into the very same error message while running NUnit 2.4.8. As I had not upgraded in some time I installed the current NUnit (v2.5.9) and found that it now supports VS2010 assemblies. So if you have newly encountered this error check your NUnit version: as of December 2010 (or so) the only thing you need to do is upgrade NUnit.
As of NUnit 2.5.10 you can enable visual studio support in the GUI runner:
Tools-> Settings-> IDE Support
After that I was able to successfully attach to the nunit-agent.exe process which runs your assembly in a .NET 4.0 app domain
If you experience this issue after upgrading to nunit 2.5.5 then you will need to upgrade nant to the latest version for me it was .91 alpha.
I found usefull to start from NUnit Application Template. It support VS C# Express, allows debugging tests and contains precompiled NUnit for .NET 4.0. Thank to author new test project gets ready with one click.

Resources