Creating Visual Studio successfully; MSBuild not working

I am trying to clean and rebuild a solution file with several projects from the command line using MSBUILD. For some reason, my build fails (about 10% of the built projects fail), and I get a few errors that look like this:

error CS0234: The type or namespace name 'foo' does not exist in the namespace 'bar' (do you miss the assembly reference?)

Now, if I clean and rebuild the same solution file from Visual Studio 2010 with the same configurations, it will be successfully created without errors.

Is there any difference in setting up or setting up MSBuild from Visual Studio that needs to be changed, which I don’t know about?

+7
visual-studio visual-studio-2010 msbuild
source share
4 answers

I just had to deal with this problem and it turns out that msbuild likes to move embedded binaries to the binaries \ release directory and reference them instead of the projects themselves when it creates things. After creating it, copies the files to this directory. This explains why it works in visual studio and not in msbuild (I am currently using TFS 1010).

In my case, I had an old binary version of the dll referenced by a project that was built after the one that was supposed to generate the correct file. The old one (binary) was rewriting the new one (built from the source), since the solution referencing the binary was built later in the assembly.

+2
source share

Try to check the path to links that MSBuild cannot find in the building library project file. Sometimes, when you use VS or ReSharper to automatically add a link for you, the path ends in the \ obj directory. VS seems to handle this, but MSBuild is not much.

+1
source share

I assume that there is a difference in how the project is created, because Visual Studio does not start MSBuild, since it rather hosts the assembly mechanism itself. This was answered here .

However, I had a similar problem.

In my case, the project referred to an external library, which was placed in the child directory of the project, unfortunately called "packages".

After starting MSBuild, the contents of the folder were deleted, presumably to load Nuget again.

The obvious solution was to rename the folder, and it worked.

+1
source share

In my case, I had one PCL referencing another PCL for different purposes. Visual Studio showed me a warning in the literature list of the first library, but compiled the solution, while MSBUILD refused to compile. I fixed the problem by redirecting the PCL. Hope this helps someone.

0
source share

All Articles