The Microsoft Build Engine (MSBuild) is the build platform for .NET and Visual Studio.
Перейти к файлу
Rainer Sigwald 88882b971b
Enable TaskHostFactory for .NET (Core) MSBuild (#6994)
Fixes #5158

Context
A task author can force any task to run out of process by specifying that it must run with TaskFactory="TaskHostFactory". But we never made this work on .NET Core; it fails with an error like

S:\msbuild\foo.proj(8,5): error MSB4216: Could not run the "Message" task because MSBuild could not create or connect to a task host with runtime "CLR4" and architecture "x64".  Please ensure that (1) the requested runtime and/or architecture are available on the machine, and (2) that the required executable "S:\msbuild\.dotnet\sdk\6.0.100-rc.1.21458.32\MSBuild.exe" exists and can be run.
That's because the "default" task host runtime was hardcoded to be CLR4 (even when on .NET 6.0+).

Changes Made
Created GetCurrentMSBuildRuntime() and used it; plumbed the new value around and checked for it in a few places. Eliminated FEATURE_TASKHOST since it's on everywhere now. Unified the named-pipe-name computation code (before it was using a different pipe name for taskhost pipes on UNIX).

Testing
Re-enabled tests for this behavior that have been disabled on .NET Core. Extended some to account for the NET runtime.

Specific steps:

* Enable out-of-proc TaskHosts on .NET Core

* Promote FEATURE_TASKHOST to no-flag-needed

This enables taskhost tests on .NET Core. Includes a couple of low-
complexity test fixes.

* Enable checking runtimetype in .tasks file

* Check runtime type in tasks file

* Extend TestRuntimeValuesMatch for net

* Extend RuntimeValuesMatch for net

* Split and shouldly-ify TestMergeRuntimeValues

* Use explicit current runtime/arch in CreatableByTaskFactoryMatchingIdentity

* Unify to NamedPipeUtil.GetPipeNameOrPath
2021-11-15 11:25:17 -08:00
.github Issue templates apply needs-triage (#6557) 2021-06-17 04:42:52 -05:00
branding Initial commit of branding (#941) 2016-08-24 08:51:47 -07:00
documentation Enable TaskHostFactory for .NET (Core) MSBuild (#6994) 2021-11-15 11:25:17 -08:00
eng Remove pinned .NET Framework ref assembly package: let SDK provide it (#6986) 2021-11-01 16:15:59 +01:00
ref Introduce public interfaces for per-project and per-evaluation disk I/O callbacks (#6728) 2021-10-21 14:28:28 +02:00
scripts Add Microsoft.IO.Redist for directory enumeration. (#6771) 2021-10-15 10:51:08 +02:00
src Enable TaskHostFactory for .NET (Core) MSBuild (#6994) 2021-11-15 11:25:17 -08:00
.editorconfig implement analyzers from runtime (#5656) 2021-08-10 16:30:54 +02:00
.gitattributes Switch eng/common to linguist-vendored (#6022) 2021-01-12 16:35:11 -06:00
.gitignore Git ignore etl trace files (#5610) 2020-08-04 11:20:19 -07:00
.vsconfig Removed unnecessary files from config file 2019-09-05 10:44:15 -07:00
.vsts-dotnet-ci.yml Update ubuntu version (#6488) 2021-06-17 04:54:51 -05:00
.vsts-dotnet.yml Merge remote-tracking branch 'upstream/vs16.11' into main 2021-09-08 14:25:50 -05:00
Directory.Build.props Remove NoWarn for NU5125 (#6900) 2021-10-04 11:24:14 -07:00
Directory.Build.rsp Add Directory.Build.rsp 2018-01-25 10:27:57 -08:00
Directory.Build.targets Delete produced packages from NuGet cache 2020-04-22 17:30:09 -07:00
LICENSE [master] Update dependencies from dotnet/arcade (#4251) 2019-03-20 21:45:47 +00:00
MSBuild.Dev.slnf Replace MSBuild.Dev.sln and MSBuild.SourceBuild.sln with solution filters (#6010) 2021-01-08 11:44:02 +01:00
MSBuild.SourceBuild.slnf Add StringTools* projects to solution files 2021-01-20 22:34:05 +01:00
MSBuild.sln Add StringTools* projects to solution files 2021-01-20 22:34:05 +01:00
NuGet.config [main] Update dependencies from dotnet/arcade (#6843) 2021-09-16 13:25:18 +02:00
PublishToBlob.proj Revert "Onboarding to V3 publishing " 2021-01-22 11:33:42 -08:00
README.md 17.1 branding (#6903) 2021-10-04 11:20:54 -07:00
THIRDPARTYNOTICES.txt Update third party notice to include Samples for xUnit.net notice 2018-01-31 18:06:44 -08:00
build.cmd Discourage building with MSBUILDDEBUGONSTART (#4952) 2019-12-10 14:46:41 -08:00
build.sh Using ProjectToBuild in Build.props to select sln file to build instead of doing it in the scripts. 2018-12-18 15:45:53 -08:00
global.json Remove reference to .NET Core 2.1 (#7030) 2021-11-12 14:36:25 -08:00

README.md

Microsoft.Build (MSBuild)

The Microsoft Build Engine is a platform for building applications. This engine, also known as MSBuild, provides an XML schema for a project file that controls how the build platform processes and builds software. Visual Studio uses MSBuild, but MSBuild can run without Visual Studio. By invoking msbuild.exe on your project or solution file, you can orchestrate and build products in environments where Visual Studio isn't installed.

For more information on MSBuild, see the MSBuild documentation on docs.microsoft.com.

The changelog has detailed information about changes made in different releases.

Build Status

The current development branch is main. Changes in main will go into a future update of MSBuild, which will release with Visual Studio 17.1 and a corresponding version of the .NET Core SDK.

Build Status

We have forked for MSBuild 17.0 in the branch vs17.0. Changes to that branch need special approval.

Build Status

16.11 builds from the branch vs16.11. Only high-priority bugfixes will be considered for servicing 16.11.

Build Status

MSBuild 16.9 builds from the branch vs16.9. Only high-priority bugfixes will be considered for servicing 16.9.

Build Status

MSBuild 16.7 builds from the branch vs16.7. Only high-priority bugfixes will be considered for servicing 16.7.

Build Status

MSBuild 15.9 builds from the branch vs15.9. Only very-high-priority bugfixes will be considered for servicing 15.9.

Building

Building MSBuild with Visual Studio 2019 on Windows

For the full supported experience, you will need to have Visual Studio 2019 or higher.

To get started on Visual Studio 2019:

  1. Install Visual Studio 2019. Select the following Workloads:
  • .NET desktop development
  • .NET Core cross-platform development
  1. Open a Developer Command Prompt for VS 2019 prompt.
  2. Clone the source code: git clone https://github.com/dotnet/msbuild
  1. Run .\build.cmd from the root of the repo to build the code. This also restores packages needed to open the projects in Visual Studio.
  2. Open MSBuild.sln or MSBuild.Dev.slnf in Visual Studio 2019.

Note: To create a usable MSBuild with your changes, run .\build.cmd /p:CreateBootstrap=true. To build release, add -c Release: .\build.cmd -c Release /p:CreateBootstrap=true.

This newly-built MSBuild will be located at artifacts\bin\bootstrap\net472\MSBuild\Current\Bin\MSBuild.exe. It may not work for all scenarios, including C++ builds.

Building MSBuild in Unix (Mac & Linux)

MSBuild can be run on Unix systems that support .NET Core. Set-up instructions can be viewed on the wiki: Building Testing and Debugging on .Net Core MSBuild

Localization

You can turn on localized builds via the /p:LocalizedBuild=true command line argument. For more information on localized builds and how to make contributions to MSBuild's translations, see our localization documentation

Interested in contributing?

Before you contribute, please read through the contributing and developer guides to get an idea of what kinds of pull requests we accept.

Other ways to contribute

We encourage any contributions you decide to make to the repo!

MSBuild Components

  • MSBuild. Microsoft.Build.CommandLine is the entrypoint for the Microsoft Build Engine (MSBuild.exe).

  • Microsoft.Build. The Microsoft.Build namespaces contain types that provide programmatic access to, and control of, the MSBuild engine.

  • Microsoft.Build.Framework. The Microsoft.Build.Framework namespace contains the types that define how tasks and loggers interact with the MSBuild engine. For additional information on this component, see our Microsoft.Build.Framework wiki page.

  • Microsoft.Build.Tasks. The Microsoft.Build.Tasks namespace contains the implementation of all tasks shipping with MSBuild.

  • Microsoft.Build.Utilities. The Microsoft.Build.Utilities namespace provides helper classes that you can use to create your own MSBuild loggers and tasks.

License

MSBuild is licensed under the MIT license.