Wednesday 23 June 2010

Building without Visual Studio


If you don’t have Visual Studio installed, maybe because this is a build server, then you will almost certainly get msbuild errors because it cannot find some tool or other from the Windows SDK.

Like:

C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1835, 9):
error MSB3454: Tracker.exe is required to correctly incrementally generate resources
in some circumstances, such as when building on a 64-bit OS using 32-bit MSBuild.
This build requires Tracker.exe, but it could not be found. The task is looking for
Tracker.exe beneath the InstallationFolder value of the registry key
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A. To solve the
problem, either: 1) Install the Microsoft Windows SDK v7.0A or later. 2) Install
Microsoft Visual Studio 2010. 3) Manually set the above registry key to the correct
location. Alternatively, you can turn off incremental resource generation by setting
the "TrackFileAccess" property to "false".

You may also get a similar message regarding LC.EXE.

The v7.0A version of the Windows SDK is installed when you install Visual Studio 2010 and is expected by the .Net 4.0 version of msbuild. However, you don’t seem to be able to get it as a separate download!

A bit of Googling shows a few “solutions. Such as adding “TrackFileAccess=false” as a configuration option for msbuild (http://bradwilson.typepad.com/blog/2010/05/working-around-build-error-msb3454.html).

This works fine for the TRACKER.EXE problem but not for the LC.EXE version.

Here’s my solution:

  1. Download the v7.1 version of Windows SDK (for .Net 4.0 and good for all version of Windows)
    http://www.microsoft.com/downloads/details.aspx?FamilyID=6b6c21d2-2006-4afa-9702-529fa782d63b&displaylang=en
    Other versions are available from the Windows SDK MSDN Developer Center (http://msdn.microsoft.com/en-us/windowsserver/bb980924.aspx)
  2. This is a web installer. If you decide to go find the full ISO of the SDK it’s around 1.6GB. The web installer lets you only select the bits you want and should download/install in a few minutes.
  3. Run winsdk_web.exe you downloaded above. Click through until you get to the “Installation Options” page.
  4. De-select everything except the .NET Development – Tools. The page should look like this

  5. On Windows 2008 server it will let you also completely unselect the Intellisense assemblies too
  6. Select next until it starts installing.
    Even on a slow connection it should only take a few minutes.
  7. Lastly you need to convince msbuild to use this version of the SDK
  8. On the Start menu you will have a “Microsoft Windows SDK v7.1” folder
  9. Select “Windows SDK 7.1 Command Prompt”
  10. Enter the following commands
    > cd Setup
    > WindowsSdkVer –version:v7.1

    See http://msdn.microsoft.com/en-us/library/ff660764.aspx (Configuring Visual Studio for Visual C++ Development with the Windows SDK) for info
  11. Done. Msbuild will now be able to find the tools it needs

You will also run into problems is you’re trying to compile web apps with an error like

error MSB4019: The imported project "C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0\WebApplications\Microsoft.WebApplication.targets" was not found. Confirm that the path in the <Import> declaration is correct, and that the file exists on disk.

Simply copy the folder “C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0” from your dev machine with VS2010 installed onto your build server.

YMMV but this is what works for me.
Good luck

10 comments:

Unknown said...

Thanks. It's really what I'm looking for

Anonymous said...

Heh, I wish I had found this post this morning.

I just spent an entire day working out most of what you posted.

Now, here I am at nearly 10pm, stuck, because after everything I have been through getting this blasted build to work, my web project won't build :).

Your post just helped me fix that BUT now I get errors about code analysis.

I found this:

http://blog.hinshelwood.com/archive/2010/03/03/solution-getting-silverlight-to-build-on-team-build-2010-rc.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+MartinHinshelwood+(Martin+Hinshelwood's+Blog)

This guy gave in when he got to where I am and installed VS.

This guy was told to do so by Microsoft guys:

http://social.msdn.microsoft.com/Forums/en/tfsbuild/thread/fc5e7c6b-0ecd-4c5f-bda2-e5c7f19221a8

It just feels so wrong....I am now going to beat my brains out on my desk.

J Milne

Andy Pook said...

Yeah, took me a few days to finally find out how to get this far.
I'm ashamed to say we don't use code analysis. But I did find this http://stackoverflow.com/questions/3075327/how-to-run-net-4-code-analysis-on-build-server

Hope this gives you some clues

Unknown said...

Thank you very much.

Setting the version manually to 7.1 solved my issue!

Best regards,
Tom

Anonymous said...

Thanks.
Setting the SDK Version manually works!!!!

Anonymous said...

It is unwise to not install Visual Studio. Especially if you are building C++ projects and use Windows SDK. Microsoft does not recommend this technically and advise you strongly not to do so as this violates the license model of the Visual Studio.

Anonymous said...

You are a lifesaver and thanks for your clear instructions.

Unknown said...

Hi, nice method for Building without Visual Studio.Thanks for your help....

Anonymous said...

Yeah... how do you solve this issue if you need .NET 3.5? :( I only need to compile a small application which I have sln project, and I don't want to download Visual Studio just for that. It always fails with 3 errors when I use MSBuild from the framework folder

Unknown said...

Yeah... how do you solve this issue if you need .NET 3.5? :( I only need to compile a small application which I have sln project, and I don't want to download Visual Studio just for that. It always fails with 3 errors when I use MSBuild from the framework folder