Skip to content

Commit f4725b9

Browse files
Error out if SelfContained is not specified for Native AOT publish
The SDK has logic to specify SelfContained for PublishAot automatically. Except this doesn't apply when we're using msbuild to run the `Publish` target (`_IsPublishing` is not set): https://github.com/dotnet/sdk/blob/75184c7e763197fa2971954aa5baf70ffd188799/src/Tasks/Microsoft.NET.Build.Tasks/targets/Microsoft.NET.RuntimeIdentifierInference.targets#L64-L83 This can lead to a bad failure mode because SelfContained is the thing that ensure ILC gets all the references to assemblies it needs. It will appear to work most of the time even without SelfContained (because ILCompiler packages carries a framework with it), but it will fail for things like ASP.NET. Enable back the logic that just errors out for this. If someone does `msbuild /t:publish` they'll get an error saying they need to also specify SelfContained instead of some weird failure mode. There was some discussion about this aspect in dotnet/sdk#28714.
1 parent 8c07adc commit f4725b9

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

src/tools/illink/src/ILLink.Tasks/build/Microsoft.NET.ILLink.targets

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,8 @@ Copyright (c) .NET Foundation. All rights reserved.
196196
<!-- The defaults currently root non-framework assemblies, which
197197
is a no-op for portable apps. If we later support more ways
198198
to customize the behavior we can allow linking portable apps
199-
in some cases. If we're not running ILLink because e.g. this
200-
is a NativeAOT app, value of SelfContained doesn't matter. -->
201-
<NETSdkError Condition="'$(RunILLink)' != 'false' And '$(SelfContained)' != 'true'" ResourceName="ILLinkNotSupportedError" />
199+
in some cases. -->
200+
<NETSdkError Condition="'$(SelfContained)' != 'true'" ResourceName="ILLinkNotSupportedError" />
202201

203202
<Warning Condition="'$(SuppressILLinkExplicitPackageReferenceWarning)' != 'true' And
204203
'%(PackageReference.Identity)' == 'Microsoft.NET.ILLink.Tasks' And '%(PackageReference.IsImplicitlyDefined)' != 'true'"

0 commit comments

Comments
 (0)