88using Microsoft . DotNet . Tools . Common ;
99using System . Collections . Generic ;
1010using Microsoft . DotNet . Cli . Utils ;
11- using System . Linq ;
12- using Microsoft . Build . Evaluation ;
13- using NuGet . Frameworks ;
1411
1512namespace Microsoft . DotNet . Cli
1613{
@@ -50,7 +47,7 @@ public static Option RuntimeOption(string description, bool withShortOption = tr
5047 description )
5148 {
5249 ArgumentHelpName = CommonLocalizableStrings . RuntimeIdentifierArgumentName
53- } . ForwardAsSingle ( o => $ "-property:RuntimeIdentifier={ o } ")
50+ } . ForwardAsMany ( o => new string [ ] { $ "-property:RuntimeIdentifier={ o } ", "-property:_CommandLineDefinedRuntimeIdentifier=true" } )
5451 . AddSuggestions ( Suggest . RunTimesFromProjectFile ( ) ) ;
5552
5653 public static Option CurrentRuntimeOption ( string description ) =>
@@ -102,13 +99,13 @@ public static Option SelfContainedOption() =>
10299 new ForwardedOption < bool > (
103100 "--self-contained" ,
104101 CommonLocalizableStrings . SelfContainedOptionDescription )
105- . ForwardAsSingle ( o => $ "-property:SelfContained={ o } ") ;
102+ . ForwardAsMany ( o => new string [ ] { $ "-property:SelfContained={ o } ", "-property:_CommandLineDefinedSelfContained=true" } ) ;
106103
107104 public static Option NoSelfContainedOption ( ) =>
108105 new ForwardedOption < bool > (
109106 "--no-self-contained" ,
110107 CommonLocalizableStrings . FrameworkDependentOptionDescription )
111- . ForwardAs ( "-property:SelfContained=false" ) ;
108+ . ForwardAsMany ( o => new string [ ] { "-property:SelfContained=false" , "-property:_CommandLineDefinedSelfContained=true" } ) ;
112109
113110 public static bool VerbosityIsDetailedOrDiagnostic ( this VerbosityOptions verbosity )
114111 {
@@ -124,26 +121,6 @@ public static void ValidateSelfContainedOptions(bool hasSelfContainedOption, boo
124121 {
125122 throw new GracefulException ( CommonLocalizableStrings . SelfContainAndNoSelfContainedConflict ) ;
126123 }
127-
128- if ( ! ( hasSelfContainedOption || hasNoSelfContainedOption ) && hasRuntimeOption )
129- {
130- projectArgs = projectArgs . Any ( ) ? projectArgs : new string [ ] { Directory . GetCurrentDirectory ( ) } ;
131- foreach ( var project in projectArgs )
132- {
133- try
134- {
135- var msbuildProj = MsbuildProject . FromFileOrDirectory ( new ProjectCollection ( ) , project , false ) ;
136- if ( msbuildProj . IsTargetingNetCoreVersionOrAbove ( NuGetFramework . Parse ( "net6.0" ) ) )
137- {
138- Reporter . Output . WriteLine ( CommonLocalizableStrings . SelfContainedOptionShouldBeUsedWithRuntime . Yellow ( ) ) ;
139- }
140- }
141- catch
142- {
143- // Project file is not valid, continue and msbuild will error
144- }
145- }
146- }
147124 }
148125 }
149126
0 commit comments