Skip to content

Commit 27f5cfe

Browse files
committed
Move runtime cli option error to targets
1 parent fa58985 commit 27f5cfe

32 files changed

+93
-112
lines changed

src/Cli/dotnet/CommonLocalizableStrings.resx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,4 @@ The default is 'true' if a runtime identifier is specified.</value>
684684
<data name="SelfContainAndNoSelfContainedConflict" xml:space="preserve">
685685
<value>The '--self-contained' and '--no-self-contained' options conflict with each other. Specify only one of the options.</value>
686686
</data>
687-
<data name="SelfContainedOptionShouldBeUsedWithRuntime" xml:space="preserve">
688-
<value>Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</value>
689-
</data>
690687
</root>

src/Cli/dotnet/CommonOptions.cs

Lines changed: 3 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
using Microsoft.DotNet.Tools.Common;
99
using System.Collections.Generic;
1010
using Microsoft.DotNet.Cli.Utils;
11-
using System.Linq;
12-
using Microsoft.Build.Evaluation;
13-
using NuGet.Frameworks;
1411

1512
namespace 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

src/Cli/dotnet/MsbuildProject.cs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -205,19 +205,6 @@ public bool IsTargetingFramework(NuGetFramework framework)
205205
return false;
206206
}
207207

208-
public bool IsTargetingNetCoreVersionOrAbove(NuGetFramework framework)
209-
{
210-
foreach (var tfm in GetTargetFrameworks())
211-
{
212-
if (tfm.Framework.Equals(".NETCoreApp") && tfm.Version >= framework.Version)
213-
{
214-
return true;
215-
}
216-
}
217-
218-
return false;
219-
}
220-
221208
private Project GetEvaluatedProject()
222209
{
223210
try

src/Cli/dotnet/xlf/CommonLocalizableStrings.cs.xlf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ The default is 'true' if a runtime identifier is specified.</source>
152152
The default is 'true' if a runtime identifier is specified.</target>
153153
<note />
154154
</trans-unit>
155-
<trans-unit id="SelfContainedOptionShouldBeUsedWithRuntime">
156-
<source>Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</source>
157-
<target state="new">Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</target>
158-
<note />
159-
</trans-unit>
160155
<trans-unit id="Solution">
161156
<source>Solution</source>
162157
<target state="translated">Řešení</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.de.xlf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ The default is 'true' if a runtime identifier is specified.</source>
152152
The default is 'true' if a runtime identifier is specified.</target>
153153
<note />
154154
</trans-unit>
155-
<trans-unit id="SelfContainedOptionShouldBeUsedWithRuntime">
156-
<source>Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</source>
157-
<target state="new">Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</target>
158-
<note />
159-
</trans-unit>
160155
<trans-unit id="Solution">
161156
<source>Solution</source>
162157
<target state="translated">Projektmappe</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.es.xlf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ The default is 'true' if a runtime identifier is specified.</source>
152152
The default is 'true' if a runtime identifier is specified.</target>
153153
<note />
154154
</trans-unit>
155-
<trans-unit id="SelfContainedOptionShouldBeUsedWithRuntime">
156-
<source>Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</source>
157-
<target state="new">Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</target>
158-
<note />
159-
</trans-unit>
160155
<trans-unit id="Solution">
161156
<source>Solution</source>
162157
<target state="translated">Solución</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.fr.xlf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ The default is 'true' if a runtime identifier is specified.</source>
152152
The default is 'true' if a runtime identifier is specified.</target>
153153
<note />
154154
</trans-unit>
155-
<trans-unit id="SelfContainedOptionShouldBeUsedWithRuntime">
156-
<source>Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</source>
157-
<target state="new">Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</target>
158-
<note />
159-
</trans-unit>
160155
<trans-unit id="Solution">
161156
<source>Solution</source>
162157
<target state="translated">Solution</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.it.xlf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ The default is 'true' if a runtime identifier is specified.</source>
152152
The default is 'true' if a runtime identifier is specified.</target>
153153
<note />
154154
</trans-unit>
155-
<trans-unit id="SelfContainedOptionShouldBeUsedWithRuntime">
156-
<source>Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</source>
157-
<target state="new">Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</target>
158-
<note />
159-
</trans-unit>
160155
<trans-unit id="Solution">
161156
<source>Solution</source>
162157
<target state="translated">Soluzione</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.ja.xlf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ The default is 'true' if a runtime identifier is specified.</source>
152152
The default is 'true' if a runtime identifier is specified.</target>
153153
<note />
154154
</trans-unit>
155-
<trans-unit id="SelfContainedOptionShouldBeUsedWithRuntime">
156-
<source>Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</source>
157-
<target state="new">Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</target>
158-
<note />
159-
</trans-unit>
160155
<trans-unit id="Solution">
161156
<source>Solution</source>
162157
<target state="translated">ソリューション</target>

src/Cli/dotnet/xlf/CommonLocalizableStrings.ko.xlf

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,11 +152,6 @@ The default is 'true' if a runtime identifier is specified.</source>
152152
The default is 'true' if a runtime identifier is specified.</target>
153153
<note />
154154
</trans-unit>
155-
<trans-unit id="SelfContainedOptionShouldBeUsedWithRuntime">
156-
<source>Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</source>
157-
<target state="new">Warning: The '--self-contained' or '--no-self-contained' option should be used with '-r|--runtime'.</target>
158-
<note />
159-
</trans-unit>
160155
<trans-unit id="Solution">
161156
<source>Solution</source>
162157
<target state="translated">솔루션</target>

0 commit comments

Comments
 (0)