How do I perform the EXEC task in a “loop” with MSBuild ItemGroups?

There are two ways to do this, both are forms of “batching” You can batch a target and perform the Exec and other operations, <Target Name=”ExecMany” Outputs=”%(CachedTables.Identity)”> <Exec Command=”sqlcmd -S … TableName=%22%(CachedTables.Identity)%22 -i …” /> <SomeOtherTask ThatUses=”%(CachedTables.Identity)” /> </Target> The other is to use task batching, just on the Exec task. It is similar, <Target … Read more

MSBuild: What is it, and when do I need it?

MSBuild is the build platform that enables all build activity in the Visual Studio world. A better, more practical example would be to state that The .csproj files (every C# project) are msbuild files When you hit F5, you basically (oversimplifying) call msbuild.exe and passing in your .csproj file. MSBuild empowers all the things that … Read more

How can I get MSBUILD to evaluate and print the full path when given a relative path?

In MSBuild 4.0, the easiest way is the following: $([System.IO.Path]::GetFullPath(‘$(MSBuildThisFileDirectory)\your\path’)) This method works even if the script is <Import>ed into another script; the path is relative to the file containing the above code. (consolidated from Aaron’s answer as well as the last part of Sayed’s answer) In MSBuild 3.5, you can use the ConvertToAbsolutePath task: … Read more

Is it possible to build MSBuild files (visual studio sln) from the command line in Mono?

Current status (Mono 2.10, 2011): xbuild is now able to build all versions of Visual Studio / MSBuild projects, including .sln files. Simply run xbuild just as you would execute msbuild on Microsoft .Net Framework. You don’t need Monodevelop installed, xbuild comes with the standard Mono installation. If your build uses custom tasks, they should … Read more

The mystery of stuck inactive msbuild.exe processes, locked Stylecop.dll, Nuget AccessViolationException and CI builds clashing with each other

After a lot of digging around and trying various things to no effect, I eventually ended up creating a new minimal solution which reproduced the issue with very little else going on. The issue turned out to be caused by msbuild’s multi-core parallelisation – the ‘m’ parameter. The ‘m’ parameter tells msbuild to spawn “nodes”, … Read more

How to build .NET 4.6 Framework app without Visual Studio installed?

Install: The .NET 4.6 Framework The Microsoft Build Tools 2015 The .NET Framework 4.6 targeting Pack Then call a different version of MsBuild to build your solution: C:\Program Files (x86)\MSBuild\14.0\Bin\MsBuild.exe MySolution.sln Note, this may not contain all bits pieces and sdk’s that ship with Visual Studio, so you may encounter “missing .targets files” or other … Read more

Is there a standard file extension for MSBuild files?

UPDATE: In retrospect, I’ve updated the answer to include more conventions. Credit goes to Sayed Ibrahim Hashimi and others on this thread. .proj A popular convention for generic use. Commonly used by a main build script. Examples: build.proj main.proj company.product.build.proj .targets .targets files are those which is meant to be imported into other files using … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)