You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: release-notes/10.0/preview/rc2/sdk.md
+27-3Lines changed: 27 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -83,11 +83,35 @@ Thanks to the `Condition` feature of MSBuild, you can load a Task differently de
83
83
Framework (Visual Studio or `msbuild.exe`) or .NET (the `dotnet` CLI). In this example, the Task will run out-of-process when
84
84
running in Visual Studio or `msbuild.exe`, but will run in-process when running in the `dotnet` CLI. This gives the best
85
85
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.
86
88
87
89
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.
0 commit comments