tags:

views:

72

answers:

3

Hi,

i'm compiling a .net 3.5 solution with msbuild with this line of code:

msbuild.exe n:\temp\Thisnight.sln /p:Configuration=Debug /v:diag

and it gives me this error:

 error CS0234: The type or namespace name 'UnitTesting' does not exist in the namespace 'Microsoft.VisualStudio.TestTools' (are you missing an assembly reference?)

i've gotten the latest source which (off course) builds in VS2010 itself.

Can't seem to figure out what i'm missing here....

EDIT

Seeing higher up in the command window this message:

  C:\Windows\Microsoft.NET\Framework\v3.5\Microsoft.Common.targets : warning MSB3245: Could not resolve this reference.
 Could not locate the assembly "Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutra
l, 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.

I don't think i have to include this DLL by my project (because it's a MS dll?)

EDIT What i've seen now: all projects are for the .Net 3.5 framework, but the testproject (which is the one giving me problems) is for the .Net 4.0 framework. And the weird thing is: i can't change it.

It's a vs2010 solution with web. webservice,winforms,dll,setup and testprojects

+1  A: 

did you run vcvars32.bat in your cmd shell?

Marco
Whow, no! what is that?
Michel
and can i also schedule it from my cruisecontrol (because when i get the msbuild running, i want to run it from my cruisecontrol), or am i to greedy now :)
Michel
It's part of the vs distribution, under the Common7\Tools folder.
Marco
i've run the batch file in my command prompt and the ran the msbuild task , but it didn't work. Any other suggestions?
Michel
by the way: it's on a dev machine, so i have VS2010 installed.
Michel
hmm. not sure. Try to open the solution in VS on that machine and see if the IDE recognizes the references in the reference tab. How did you reference this DLL? You could try deleting the reference and re-adding it to the project again. VS runs msbuild to build the project, so it must be a subtle difference in the environment in which the process starts. Also - are you sure it is the same type of VS2010 install? The test environment is not available in the base version, only on some versions (like Professional and Test)
Marco
It's ON my dev machine, so the machine i'm running msbuild on is the same machine i developed the solution on. And the dll's were reference by the project once i created it by a simple file, new project, test project. But i'll try to delete and re-add them, maybe that helps.
Michel
it seems that it is missing for this assembly c:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll
Michel
i tried adding it to the msbuild with /p:AddModules and /p:AssemblySearchPaths, but unfortunately, didn't work
Michel
and i can't figure out where to look for the MSbuild command(s) VS executes when it compiles my solution
Michel
+1  A: 

If you look at the Microsoft.Common.Targets file you will see :

<!--
    The SearchPaths property is set to find assemblies in the following order:

        (1) Files from current project - indicated by {CandidateAssemblyFiles}
        (2) $(ReferencePath) - the reference path property, which comes from the .USER file.
        (3) The hintpath from the referenced item itself, indicated by {HintPathFromItem}.
        (4) The directory of MSBuild's "target" runtime from GetFrameworkPath.
            The "target" runtime folder is the folder of the runtime that MSBuild is a part of.
        (5) Registered assembly folders, indicated by {Registry:*,*,*}
        (6) Legacy registered assembly folders, indicated by {AssemblyFolders}
        (7) Resolve to the GAC.
        (8) Treat the reference's Include as if it were a real file name.
        (9) Look in the application's output folder (like bin\debug)
    -->

VS runs MSBuild in its own environment, I don't know the differences either but did you try adding the lacking assembly path in command line by modifying the AssemblyFolders items. You have a tuto here : http://www.beefycode.com/post/Resolving-Binary-References-in-MSBuild.aspx .

Hope this helps.

Benjamin Baumann
Hi,i did try this: /p:AssemblySearchPaths ......
Michel
Not sure if you can override AssemblySearchPaths in command line. Did you try adding a custom target like it's shown in the tuto? Or else you could directly modify Microsoft.Common.Targets but I don't think it's a good solution...
Benjamin Baumann
A: 

try running:

msbuild /version

Make sure it's the 3.5 version and not something older.

Make sure the MS dll is here, or somewhere like that:

C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll

jgritty