windows 7 - How can I compile a .NET project without having Visual Studio installed?

07
2014-07
  • Oliver Salzburg

    I want to compile a .NET/C# project, but I don't want to install Visual Studio to do this.

    What tools do I need and how can I compile the project?

  • Answers
  • Oliver Salzburg
    1. Download and install the latest .NET Framework.
      For example, you can use the installer for the .NET Framework 4.5 installer.

    2. Open a command prompt and change into the installation directory of the .NET Framework.
      For example:

      cd \Windows\Microsoft.NET\Framework\v4*
      
    3. Use MSBuild.exe to compile your solution.
      For example:

      msbuild "C:\Users\Oliver\Documents\My Project\My Project.sln" /t:Rebuild /p:Configuration=Release /p:Platform="Any CPU"

    In case the project uses NuGet packages, you can follow these steps to retrieve them:

    1. Download the NuGet.exe Command Line boostrapper and, for example, place it inside the solution directory.

    2. Open a command prompt and change into the solution directory.
      For example:

      cd "C:\Users\Oliver\Documents\My Project"
      
    3. Invoke NuGet.exe to update the packages required for this solution:

      NuGet.exe install "My Project/packages.config" -o packages/
      
  • Breakthrough

    If you want to avoid installing Visual Studio, you might want to try Mono, a cross-platform and open source .NET runtime and development framework. Mono is based on the published ECMA standard for C# and is directly compatible with pre-compiled C# applications.

    Mono also includes a tool called XBuild which can fully replace MSBuild. See this article from the Mono project regarding porting a project from MSBuild to XBuild. A one-line description of XBuild from the Wiki:

    xbuild is Mono's implementation of msbuild and it allows projects that have an msbuild file to be compiled natively on Linux.

    Note that in addition to Linux, Windows and Mac OS X are also supported.


  • Related Question

    eclipse - Why does installing Visual Studio 2010 beta require a restart?
  • Elazar Leibovich

    Why does Visual Studio 2010 require installation with MSI and reboot just in order to make it work, where Eclipse, which is based on similar architecture (JVM instead of the CLR) requires just pasting the files somewhere on the disk.

    I can accept having to install .Net 4.0 through MSI (just like Java) but why can't the Visual Studio itself be "installed" like Eclipse does?


  • Related Answers
  • RBerteig

    I believe that a full install includes things like MS SQL Server, which has components that run as services. I'm not surprised if they don't worry too much about making a developer reboot rather than arrange to properly shut down those services before the install and restart them after.

    Also, a lot of their developer products have historically tweaked the PATH and other environment variables, and rather than take the support calls from people eager to dive right in and see Hello World work out or the box, they seem to prefer forcing a reboot as the easiest way to guarantee that the command prompt and the running copy of Explorer agree on life.

  • Manuel Faux

    Is a restart such a big problem for you?

    Visual Studio is a very complex set of software which comes with loads of extras like Microsoft SQL Server, Crystal Reports, etc.. It also needs to register itself as a debugger and many DLLs, which also may cause a system restart. Eclipse does not register a global application debugger nor registers any DLL.

    Furthermore is the .NET architecture completely different from the Java architecture, you cannot compare such abstract pieces of frameworks.

  • erichui

    There are probably a plethora of reasons. However, based upon the installation of previous version of Visual Studio, one reason is the over-writing of certain DLLs that may be in use.

    For example, the the C runtime library (dll) may currently be in use by some processes. The reboot is necessary so that a run-at-boot script can copy over the DLL (with a newer version) before any process loads the DLL.