Questions tagged [msbuild]

Microsoft Build Engine, also known as MSBuild, is a build platform for managed code and was part of .NET Framework.

MSBuild is a build tool that helps automate the process of creating a software product, including compiling the source code, packaging, testing, deployment and creating documentations. With MSBuild, it is possible to build Visual Studio projects and solutions without the Visual Studio IDE installed. MSBuild is available at no cost. MSBuild was previously bundled with .NET Framework; starting with Visual Studio 2013, however, it is bundled with Visual Studio instead. MSBuild is a functional replacement for the nmake utility, the latter of which remains in use in projects that originated in older Visual Studio releases.

MSBuild acts on MSBuild project files which have a similar XML syntax to Apache Ant or NAnt. Even though the syntax is based upon well-defined XML schema, the fundamental structure and operation is comparable to the traditional Unix make utility: the user specifies what will be used (typically source code files) and what the result should be (typically an application), but the utility itself decides what to do and the order in which to do it.

MSBuild can build a project against a supported .NET Framework version of choice. This feature is called "multitargeting". Any given build of a project, however, can only target one version of the framework at a time.

FAQ

Resources

14915 questions
190
votes
6 answers

List of MSBuild built-in variables

How can I get a list of built-in MSBuild variables? I need to know how to determine the current project's csproj name, and thought it might be useful to know what else I can find out in MSBuild.
Khanzor
  • 4,830
  • 3
  • 25
  • 41
184
votes
23 answers

Get Visual Studio to run a T4 Template on every build

How do I get a T4 template to generate its output on every build? As it is now, it only regenerates it when I make a change to the template. I have found other questions similar to this: T4 transformation and build order in Visual Studio…
JoelFan
  • 37,465
  • 35
  • 132
  • 205
179
votes
7 answers

The default XML namespace of the project must be the MSBuild XML namespace

I cloned the ASP.NET Core SignalR Repo locally, and try opening the solution from within the following environment. IDE Microsoft Visual Studio Enterprise 2015 Version 14.0.25431.01 Update 3 Microsoft .NET Framework Version 4.6.01055 DOT NET CLI λ…
David Pine
  • 23,787
  • 10
  • 79
  • 107
178
votes
2 answers

Delphi XE custom build target is always disabled

I've created a custom MSBuild .targets file that I've included in a Delphi XE project via the IDE and enabled it from the Project Manager's context menu. Although the file validates, it always gets disabled after I re-save the project file. Here's a…
delphidabbler
  • 1,899
  • 1
  • 11
  • 7
169
votes
6 answers

How do I get .NET Core projects to copy NuGet references to the build output?

I'm trying to write a plugin system with .NET Core, and one of my requirements are to be able to distribute the plugin DLL along with its dependencies to the user for install. However, I can't figure out how to include my NuGet dependencies as a…
chyyran
  • 2,446
  • 2
  • 21
  • 35
165
votes
2 answers

What does the Private setting do on a ProjectReference in a MSBuild project file?

I saw this in a project file the other day: {A GUID HERE} Baz False
Billy ONeal
  • 104,103
  • 58
  • 317
  • 552
164
votes
18 answers

What is the best practice for "Copy Local" and with project references?

I have a large c# solution file (~100 projects), and I am trying to improve build times. I think that "Copy Local" is wasteful in many cases for us, but I am wondering about best practices. In our .sln, we have application A depending on assembly B…
Dave Moore
  • 4,397
  • 7
  • 25
  • 34
163
votes
14 answers

NAnt or MSBuild, which one to choose and when?

I am aware there are other NAnt and MSBuild related questions on Stack Overflow, but I could not find a direct comparison between the two and so here is the question. When should one choose NAnt over MSBuild? Which one is better for what? Is NAnt…
Yordan Pavlov
  • 5,126
  • 4
  • 25
  • 15
160
votes
5 answers

'Specified condition "$(PackageAsSingleFile)" evaluates to "" instead of a boolean?

The visual studio 2012 on my PC get the following error message when preview in the "Public Web". I need to restart VS to get rid of the error message. Invoke build failed due to exception 'Specified condition "$(PackageAsSingleFile)" evaluates to…
ca9163d9
  • 27,283
  • 64
  • 210
  • 413
153
votes
24 answers

MSBUILD : error MSB1008: Only one project can be specified

Why am I getting the following Build error? C:\WINDOWS\Microsoft.NET\Framework\v3.5\msbuild.exe C:\Code\EduBenesysNET\EduBenesysNET\EduBenesysNET.vbproj /t:publish /p:Configuration=Release /p:Platform=AnyCPU /v:detailed…
Gerhard Weiss
  • 9,343
  • 18
  • 65
  • 67
152
votes
7 answers

Should I compile with /MD or /MT?

In Visual Studio, there's the compile flags /MD and /MT which let you choose which kind of C runtime library you want. I understand the difference in implementation, but I'm still not sure which one to use. What are the pros/cons? One advantage to…
andy
  • 18,005
  • 9
  • 30
  • 27
151
votes
15 answers

remove nuget package restore from solution

I added the recent nuget package restore feature to a solution using 'Enable NuGet Package Restore': http://docs.nuget.org/docs/workflows/using-nuget-without-committing-packages However it broke my build server and I didn't have the time to fix it,…
Wiebe Tijsma
  • 10,173
  • 5
  • 52
  • 68
144
votes
4 answers

How to escape quote marks in Exec Command in MSBuild

I'm trying to build an MSBuild script that maps a network drive to a drive letter in the script, but unfortunately the path to the target folder includes an embedded space. The embedded space causes the mapping to fail, and I don't know if it is…
Cyberherbalist
  • 12,061
  • 17
  • 83
  • 121
144
votes
22 answers

How to fully clean bin and obj folders within Visual Studio?

If you right click on a folder, you will see a "Clean" menu item. I assumed this would clean (remove) the obj and bin directory. However, as far as I can see, it does nothing. Is there another way? (please don't tell me to go to Windows Explorer or…
tom7
  • 4,062
  • 8
  • 30
  • 30
142
votes
5 answers

specify project file of a solution using msbuild

I want the commandline for building a particular project of a solution using msbuild like we do with devenv.com.In devenv.com we can specify a project of a solution using following commandline devenv.com /Build Release|x86 test.sln /project…
mystack
  • 4,910
  • 10
  • 44
  • 75