Questions tagged [microsoft.build]

MSBuild is a Microsoft build platform typically used in conjunction with Visual Studio. MSBuild version 2.0 is part of .NET Framework 2.0 and works together with Visual Studio 2005. Version 3.5 of MSBuild, which is bundled together with .NET 3.5 (and Visual Studio 2008), allows .NET projects to be built for either 2.0, 3.0 or 3.5 .NET version support (also known as"multi-targeting").

MSBuild is a Microsoft build platform typically used in conjunction with Visual Studio. MSBuild version 2.0 is part of .NET Framework 2.0 and works together with Visual Studio 2005. Version 3.5 of MSBuild, which is bundled together with .NET 3.5 (and Visual Studio 2008), allows .NET projects to be built for either 2.0, 3.0 or 3.5 .NET version support (also known as"multi-targeting").

It is possible to build Visual Studio projects and solutions without the Visual Studio IDE installed. MSBuild is available at no cost.

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.

42 questions
16
votes
1 answer

How to have Visual Studio 2017 accept modifications to csproj file

I've developed a code generator for internal use where code assets (POCOs) are generated based off of C# interfaces. The code generation process programmatically adds/removes items to csproj file. The workflow is as follows: a developer adds a new…
Tom Schreck
  • 5,177
  • 12
  • 68
  • 122
10
votes
1 answer

Force BuildManager to use another version of MSBuild

The following code tries to build a Solution programmatically, using BuildManager: ProjectCollection pc = new ProjectCollection(); pc.DefaultToolsVersion = "12.0"; pc.Loggers.Add(fileLogger); Dictionary globalProperty = new…
Maria Ines Parnisari
  • 16,584
  • 9
  • 85
  • 130
6
votes
2 answers

Programmatically modify Assembly Binding

I have an issue working with Microsoft.Build.BuildEngine which supposed to get fixed modifing my .exe.config file to add the following.
sebagomez
  • 9,501
  • 7
  • 51
  • 89
4
votes
2 answers

Building WPF application using Microsoft.Build assemblies

I am trying to perform a build on a WPF (.Net Framework 4.0) project using the Microsoft.Build assemblies, i.e. not building from VS and not building using stock standard MSBuild from command line. All my projects build successfully, but the WPF…
NubieJ
  • 575
  • 2
  • 9
  • 21
4
votes
2 answers

EventSourceException: No Free Buffers available from the operating system

The full exception text is: EventSourceException: No Free Buffers available from the operating system (e.g. event rate too fast). I am calling this method approx a million times because of recursion. It does not stop, I just get the exception…
thomas nn
  • 933
  • 3
  • 13
  • 21
4
votes
0 answers

Building a .sln file with Microsoft.Build

I'm using VS2012 and I want to build a .sln file programatically using c#. I understand I need to use the Microsoft.Build api to do so. I've gotten as far as building the solution string slnPath= @"C:\Path\To\solution.sln"; ProjectCollection pc =…
maccard
  • 1,198
  • 4
  • 17
  • 34
4
votes
2 answers

Adding a Postbuild event to a project

When I generate a C# project (csproj file) and then compile it, msbuild somehow doesn’t recognize the variables $(ConfigurationName) and $(ProjectDir) (and others) in the pre- and postbuild event. When I Manually move the pre- and postbuild event…
Alfons
  • 511
  • 4
  • 17
4
votes
0 answers

How C# msbuild use build engine log

I wanna use msbuild in C#, there are 2 approach: we have a build engine to compile some xmls, and the engine has its own logging system. 1) Call msbuild in C# Process P=new Process(); p.StartInfo.FileName=... This works, but I wanna a more…
L_G
  • 209
  • 2
  • 10
3
votes
3 answers

project.assets.json doesn't have a target for 'net472'. Ensure that restore has run and that you have included 'net472' VS2019

I get this error when i try to build the app. I think somehow i need to do a .net restore but i dont know if it will work.. And i want to make it via code. The .csproj:
user14723892
3
votes
2 answers

Error compiling C# 6 with Microsoft.Build ( Visual Studio SDK )

This is a working C#6 test code. It compiles on VS2015 namespace testcode { class Program { static void Main(string[] args) { string x = null ; string y = x?.Substring(0, 2); return; …
xvan
  • 4,554
  • 1
  • 22
  • 37
3
votes
2 answers

Build API - Restore nuget packages

I created an app that builds all the solutions I have using the Build API (https://msdn.microsoft.com/en-us/library/dn715758(v=vs.121).aspx). The problem I am facing, is that it does not trigger the nuget package restore. Which means that if it's…
Johan
  • 8,068
  • 1
  • 33
  • 46
3
votes
1 answer

How to create solution with multiple projects programmatically?

I want to create solution with multiple projects. I think I have three options: EnvDTE Microsoft.Build Manually create *.sln and *.csproj files I googled but didn't found good examples for 1 and 2 options (I mean how to create solution, add…
Vano Maisuradze
  • 5,829
  • 6
  • 45
  • 73
2
votes
1 answer

Different releases of Microsoft.Build.* assemblies have the same 15.1 version leading to issues

It seems like at some point assemblies Microsoft.Build, Microsoft.Build.Framework, etc. stopped changing their versions after updates, so the versions of actually different Microsoft.Build assemblies became the same (15.1). If an application depends…
2
votes
1 answer

How can I use an SLN file with MSBuild programmatically from C#?

I am trying to create a custom MSBuild script in C#, using the newer Microsoft.Build.Evaluation API. The problem I have is that this newer API does not support .sln files. The older deprecated Microsoft.Build.Engine API does support .sln files,…
JamesFaix
  • 8,050
  • 9
  • 37
  • 73
2
votes
0 answers

Generate .cs file and include in project

Brief I'm generating .cs files and then automatically including the files in specified projects (If you're interested on how view this question). I can run the function and the files are included as expected. Issue I remove the files manually from…
Aetbmo
  • 123
  • 1
  • 8
1
2 3