Skip to content

Commit 0143386

Browse files
baronfeljongallowayCopilot
authored
Update .NET TaskHost docs with some more caveats (#10127)
* Update .NET TaskHost docs with some more caveats * Fix markdown formatting in .NET 10 RC2 SDK release notes * Update release-notes/10.0/preview/rc2/sdk.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Jon Galloway <jongalloway@gmail.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 2be74c9 commit 0143386

File tree

1 file changed

+27
-3
lines changed
  • release-notes/10.0/preview/rc2

1 file changed

+27
-3
lines changed

release-notes/10.0/preview/rc2/sdk.md

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,35 @@ Thanks to the `Condition` feature of MSBuild, you can load a Task differently de
8383
Framework (Visual Studio or `msbuild.exe`) or .NET (the `dotnet` CLI). In this example, the Task will run out-of-process when
8484
running in Visual Studio or `msbuild.exe`, but will run in-process when running in the `dotnet` CLI. This gives the best
8585
performance when running in the `dotnet` CLI, while still allowing the Task to be used in Visual Studio and `msbuild.exe`.
86+
A [future version](https://github.com/dotnet/msbuild/pull/12642) will simplify this syntax so that only the `Runtime="NET"`
87+
addition is required.
8688

8789
There are also small technical limitations to be aware of when using .NET Tasks in MSBuild - the most notable of which is
88-
that the `Host Object` feature of MSBuild Tasks is not yet supported for .NET Tasks running out-of-process. This means
89-
that if your Task relies on a Host Object, it will not work when running in Visual Studio or `msbuild.exe`. We are actively
90-
working on adding support for Host Objects in future releases.
90+
that the `Host Object` feature of MSBuild Tasks is [not yet supported](https://github.com/dotnet/msbuild/issues/11510) for .NET
91+
Tasks running out-of-process. This means that if your Task relies on a Host Object, it will not work when running in Visual Studio
92+
or `msbuild.exe`. We are actively working on adding support for Host Objects in future releases.
93+
94+
> [!IMPORTANT]
95+
> Support for `Runtime="NET"` is only available in Visual Studio 2026/MSBuild.exe version 18.0 and above.
96+
97+
Loading a Task declared with `Runtime="NET"` in an earlier version of Visual Studio or MSBuild.exe will result in an error like the following:
98+
99+
```text
100+
System.AggregateException: One or more errors occurred. ---> Microsoft.Build.Exceptions.BuildAbortedException: Build was canceled.
101+
MSBuild.exe could not be launched as a child node as it could not be found at the location "C:\Program Files\Microsoft Visual Studio\2026\Preview\MSBuild\Current\Bin\amd64\MSBuild.dll". If necessary, specify the correct location in the BuildParameters, or with the MSBUILD_EXE_PATH environment variable.
102+
at Microsoft.Build.BackEnd.NodeLauncher.StartInternal(String msbuildLocation, String commandLineArgs)
103+
at Microsoft.Build.BackEnd.NodeLauncher.DisableMSBuildServer(Func`1 func)
104+
at Microsoft.Build.BackEnd.NodeProviderOutOfProcBase.<>c__DisplayClass14_0.<GetNodes>g__StartNewNode|2(Int32 nodeId)
105+
at Microsoft.Build.BackEnd.NodeProviderOutOfProcBase.<>c__DisplayClass14_0.<GetNodes>b__0(Int32 nodeId)
106+
```
107+
108+
For this reason, you will likely need two `UsingTask` elements for each Task you want to load:
109+
110+
- one comparing against `MSBuild::VersionGreaterThanOrEquals('$(MSBuildVersion)', '18.0.0')` for environments that support the .NET TaskHost
111+
- one comparing against `MSBuild::VersionLessThan('$(MSBuildVersion)', '18.0.0')` for environments that do not support the .NET TaskHost
112+
113+
If you don't do this UsingTask-based version detection, then you should have some other kind of version-checking that issues
114+
some kind of warning message to a user that they are using an unsupported configuration.
91115

92116
### Future work
93117

0 commit comments

Comments
 (0)