Skip to content

Commit a2848db

Browse files
Support for .NET SDK 9
1 parent 8c244a4 commit a2848db

File tree

18 files changed

+72
-75
lines changed

18 files changed

+72
-75
lines changed

Build/Build.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<ItemGroup>
1313
<ProjectReference Include="..\CSharpInteractive.HostApi\CSharpInteractive.HostApi.csproj"/>
1414
<ProjectReference Include="..\CSharpInteractive\CSharpInteractive.csproj"/>
15-
<PackageReference Include="TeamCity.DotNet.Integration" Version="1.0.32" PrivateAssets="all" GeneratePathProperty="true" ExcludeAssets="All" IncludeAssets="none"/>
15+
<PackageReference Include="TeamCity.DotNet.Integration" Version="1.0.33" PrivateAssets="all" GeneratePathProperty="true" ExcludeAssets="All" IncludeAssets="none" />
1616
<Using Include="System"/>
1717
<Using Include="System.Collections.Generic"/>
1818
<Using Include="System.IO"/>

CSharpInteractive.HostApi/DotNetCommands.cs

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,7 @@ public IStartInfo GetStartInfo(IHost host)
834834
.AddArgs(Output.ToArgs("--output", ""))
835835
.AddArgs(OS.ToArgs("--os", ""))
836836
.AddArgs(Runtime.ToArgs("--runtime", ""))
837-
.AddArgs(TerminalLogger.ToArgs("--tl", ""))
837+
.AddArgs(TerminalLogger.ToArgs("--tl", ":"))
838838
.AddArgs(Verbosity.ToArgs("--verbosity", ""))
839839
.AddArgs(VersionSuffix.ToArgs("--version-suffix", ""))
840840
.AddBooleanArgs(
@@ -1013,7 +1013,7 @@ public IStartInfo GetStartInfo(IHost host)
10131013
.AddArgs(Framework.ToArgs("--framework", ""))
10141014
.AddArgs(Output.ToArgs("--output", ""))
10151015
.AddArgs(Runtime.ToArgs("--runtime", ""))
1016-
.AddArgs(TerminalLogger.ToArgs("--tl", ""))
1016+
.AddArgs(TerminalLogger.ToArgs("--tl", ":"))
10171017
.AddArgs(Verbosity.ToArgs("--verbosity", ""))
10181018
.AddBooleanArgs(
10191019
("--nologo", NoLogo),
@@ -4059,7 +4059,7 @@ public IStartInfo GetStartInfo(IHost host)
40594059
.AddArgs(Output.ToArgs("--output", ""))
40604060
.AddArgs(OS.ToArgs("--os", ""))
40614061
.AddArgs(Runtime.ToArgs("--runtime", ""))
4062-
.AddArgs(TerminalLogger.ToArgs("--tl", ""))
4062+
.AddArgs(TerminalLogger.ToArgs("--tl", ":"))
40634063
.AddArgs(Verbosity.ToArgs("--verbosity", ""))
40644064
.AddArgs(VersionSuffix.ToArgs("--version-suffix", ""))
40654065
.AddBooleanArgs(
@@ -4210,7 +4210,7 @@ public IStartInfo GetStartInfo(IHost host)
42104210
///
42114211
/// new DotNetPublish()
42124212
/// .WithWorkingDirectory("MyLib")
4213-
/// .WithFramework("net8.0")
4213+
/// .WithFramework(framework)
42144214
/// .WithOutput("bin")
42154215
/// .Build().EnsureSuccess();
42164216
///</code>
@@ -4314,7 +4314,7 @@ public IStartInfo GetStartInfo(IHost host)
43144314
.AddArgs(Output.ToArgs("--output", ""))
43154315
.AddArgs(OS.ToArgs("--os", ""))
43164316
.AddArgs(Runtime.ToArgs("--runtime", ""))
4317-
.AddArgs(TerminalLogger.ToArgs("--tl", ""))
4317+
.AddArgs(TerminalLogger.ToArgs("--tl", ":"))
43184318
.AddArgs(Verbosity.ToArgs("--verbosity", ""))
43194319
.AddArgs(VersionSuffix.ToArgs("--version-suffix", ""))
43204320
.AddBooleanArgs(
@@ -4445,7 +4445,7 @@ public IStartInfo GetStartInfo(IHost host)
44454445
.AddArgs(LockFilePath.ToArgs("--lock-file-path", ""))
44464446
.AddArgs(Packages.ToArgs("--packages", ""))
44474447
.AddArgs(Runtime.ToArgs("--runtime", ""))
4448-
.AddArgs(TerminalLogger.ToArgs("--tl", ""))
4448+
.AddArgs(TerminalLogger.ToArgs("--tl", ":"))
44494449
.AddArgs(Verbosity.ToArgs("--verbosity", ""))
44504450
.AddBooleanArgs(
44514451
("--disable-build-servers", DisableBuildServers),
@@ -4486,9 +4486,6 @@ public IStartInfo GetStartInfo(IHost host)
44864486
/// .WithProject(Path.Combine("MyApp", "MyApp.csproj"))
44874487
/// .Build(message =&gt; stdOut.Add(message.Text))
44884488
/// .EnsureSuccess();
4489-
///
4490-
/// // Checks stdOut
4491-
/// stdOut.ShouldBe(new[] {"Hello, World!"});
44924489
///</code>
44934490
/// </example>
44944491
/// </summary>
@@ -4570,7 +4567,7 @@ public IStartInfo GetStartInfo(IHost host)
45704567
.AddArgs(OS.ToArgs("--os", ""))
45714568
.AddArgs(Project.ToArgs("--project", ""))
45724569
.AddArgs(Runtime.ToArgs("--runtime", ""))
4573-
.AddArgs(TerminalLogger.ToArgs("--tl", ""))
4570+
.AddArgs(TerminalLogger.ToArgs("--tl", ":"))
45744571
.AddArgs(Verbosity.ToArgs("--verbosity", ""))
45754572
.AddBooleanArgs(
45764573
("--force", Force),
@@ -5014,11 +5011,6 @@ public IStartInfo GetStartInfo(IHost host)
50145011
/// var result = new DotNetTest()
50155012
/// .WithWorkingDirectory("MyTests")
50165013
/// .Build().EnsureSuccess();
5017-
///
5018-
/// // The "result" variable provides details about build and tests
5019-
/// result.ExitCode.ShouldBe(0, result.ToString());
5020-
/// result.Summary.Tests.ShouldBe(1, result.ToString());
5021-
/// result.Tests.Count(test =&gt; test.State == TestState.Finished).ShouldBe(1, result.ToString());
50225014
///</code>
50235015
/// </example>
50245016
/// </summary>
@@ -5056,6 +5048,7 @@ public IStartInfo GetStartInfo(IHost host)
50565048
/// <param name="ListTests">List the discovered tests instead of running the tests.</param>
50575049
/// <param name="Verbosity">Sets the verbosity level of the command. Allowed values are <see cref="DotNetVerbosity.Quiet"/>, <see cref="DotNetVerbosity.Minimal"/>, <see cref="DotNetVerbosity.Normal"/>, <see cref="DotNetVerbosity.Detailed"/>, and <see cref="DotNetVerbosity.Diagnostic"/>. The default is <see cref="DotNetVerbosity.Minimal"/>. For more information, see <see cref="DotNetVerbosity"/>.</param>
50585050
/// <param name="Diagnostics">Enables diagnostic output.</param>
5051+
/// <param name="TerminalLogger">Specifies whether the terminal logger should be used for the build output.</param>
50595052
/// <param name="ShortName">Specifies a short name for this operation.</param>
50605053
[Target]
50615054
public partial record DotNetTest(
@@ -5091,6 +5084,7 @@ public partial record DotNetTest(
50915084
bool? ListTests = default,
50925085
DotNetVerbosity? Verbosity = default,
50935086
bool? Diagnostics = default,
5087+
DotNetTerminalLogger? TerminalLogger = default,
50945088
string ExecutablePath = "",
50955089
string WorkingDirectory = "",
50965090
string ShortName = "")
@@ -5146,6 +5140,7 @@ public IStartInfo GetStartInfo(IHost host)
51465140
.AddArgs(Runtime.ToArgs("--runtime", ""))
51475141
.AddArgs(Settings.ToArgs("--settings", ""))
51485142
.AddArgs(Verbosity.ToArgs("--verbosity", ""))
5143+
.AddArgs(TerminalLogger.ToArgs("--tl", ":"))
51495144
.AddBooleanArgs(
51505145
("--blame", Blame),
51515146
("--blame-crash", BlameCrash),

CSharpInteractive.HostApi/DotNetCommands.tt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,15 @@ using Internal;
4141
var forceArg = new Arg("Force", "--force", "bool?", "Forces all dependencies to be resolved even if the last restore was successful. Specifying this flag is the same as deleting the project.assets.json file.");
4242
var archArg = new Arg("Arch", "--arch", "string", "Specifies the target architecture. This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --arch x86 sets the RID to win-x86. If you use this option, don&apos;t use the -r|--runtime option. Available since .NET 6 Preview 7.");
4343
var osArg = new Arg("OS", "--os", "string", "Specifies the target operating system (OS). This is a shorthand syntax for setting the Runtime Identifier (RID), where the provided value is combined with the default RID. For example, on a win-x64 machine, specifying --os linux sets the RID to linux-x64. If you use this option, don&apos;t use the -r|--runtime option. Available since .NET 6.");
44-
var terminalLoggerArg = new Arg("TerminalLogger", "--tl", "DotNetTerminalLogger?", "Specifies whether the terminal logger should be used for the build output.");
44+
var terminalLoggerArg = new Arg("TerminalLogger", "--tl", "DotNetTerminalLogger?", "Specifies whether the terminal logger should be used for the build output.") { Separator = ":" };
4545
var artifactsPathArg = new Arg("ArtifactsPath", "--artifacts-path", "string", "All build output files from the executed command will go in subfolders under the specified path, separated by project.");
4646
var disableBuildServersArg = new Arg("DisableBuildServers", "--disable-build-servers", "bool?", "Forces the command to ignore any persistent build servers. This option provides a consistent way to disable all use of build caching, which forces a build from scratch. A build that doesn't rely on caches is useful when the caches might be corrupted or incorrect for some reason. Available since .NET 7 SDK.");
4747
var outputArg = new Arg("Output", "--output", "string", "Directory in which to place the built binaries. If not specified, the default path is ./bin/&lt;configuration&gt;/&lt;framework&gt;/. For projects with multiple target frameworks (via the TargetFrameworks property), you also need to define --framework when you specify this option.");
4848
var useCurrentRuntimeArg = new Arg("UseCurrentRuntime", "--use-current-runtime", "bool?", "Sets the RuntimeIdentifier to a platform portable RuntimeIdentifier based on the one of your machine. This happens implicitly with properties that require a RuntimeIdentifier, such as SelfContained, PublishAot, PublishSelfContained, PublishSingleFile, and PublishReadyToRun. If the property is set to false, that implicit resolution will no longer occur.");
4949
var versionSuffixArg = new Arg("VersionSuffix", "--version-suffix", "string", "Sets the value of the $(VersionSuffix) property to use when building the project. This only works if the $(Version) property isn't set. Then, $(Version) is set to the $(VersionPrefix) combined with the $(VersionSuffix), separated by a dash.");
5050
var templateNameArg = new Arg("TemplateName", "", "string", "The template to instantiate when the command is invoked. Each template might have specific options you can pass.") { IsProject = true };
5151
var languageArg = new Arg("Language", "--language", "DotNetLanguage?", "");
52-
var ownersArg = new Arg("Owners", "--owners", "IEnumerable<string>", "List of trusted owners to further restrict the trust of a repository.") { IsCollection = true, CollectionSeparator = ","};
52+
var ownersArg = new Arg("Owners", "--owners", "IEnumerable<string>", "List of trusted owners to further restrict the trust of a repository.") { IsCollection = true, Separator = ","};
5353
var allowUntrustedRootArg = new Arg("AllowUntrustedRoot", "--allow-untrusted-root", "bool?", "Specifies if the certificate for the trusted signer should be allowed to chain to an untrusted root. This is not recommended.");
5454
var configFileArg = new Arg("ConfigFile", "--configfile", "string", "The NuGet configuration file (nuget.config) to use. If specified, only the settings from this file will be used. If not specified, the hierarchy of configuration files from the current directory will be used.");
5555
var sourcesArg = new Arg("Sources", "--source", "IEnumerable<string>", "The URI of the NuGet package source to use during this operation.") { IsCollection = true };
@@ -60,14 +60,14 @@ using Internal;
6060
var includePreviewsArg = new Arg("IncludePreviews", "--include-previews", "bool?", "Allows prerelease workload manifests.");
6161
var skipManifestUpdateArg = new Arg("SkipManifestUpdate", "--skip-manifest-update", "bool?", "Skip updating the workload manifests. The workload manifests define what assets and versions need to be installed for each workload.");
6262
var tempDirArg = new Arg("TempDir", "--temp-dir", "string", "Specify the temporary directory used to download and extract NuGet packages (must be secure).");
63-
var includesArg = new Arg("Includes", "--include", "IEnumerable<string>", "A list of relative file or folder paths to include in formatting. The default is all files in the solution or project.") {IsCollection = true, CollectionSeparator = " "};
64-
var excludesArg = new Arg("Excludes", "--exclude", "IEnumerable<string>", "A space-separated list of relative file or folder paths to exclude from formatting. The default is none.") {IsCollection = true, CollectionSeparator = " "};
63+
var includesArg = new Arg("Includes", "--include", "IEnumerable<string>", "A list of relative file or folder paths to include in formatting. The default is all files in the solution or project.") {IsCollection = true, Separator = " "};
64+
var excludesArg = new Arg("Excludes", "--exclude", "IEnumerable<string>", "A space-separated list of relative file or folder paths to exclude from formatting. The default is none.") {IsCollection = true, Separator = " "};
6565
var dotNetFormatSeverityArg = new Arg("Severity", "--severity", "DotNetFormatSeverity?", "The minimum severity of diagnostics to fix. Allowed values are <c>Information</c>, <c>Warning</c>, and <c>Error</c>. The default value is <c>Warning</c>.");
6666
var verifyNoChangesArg = new Arg("VerifyNoChanges", "--verify-no-changes", "bool?", "Verifies that no formatting changes would be performed. Terminates with a non zero exit code if any files would have been formatted.");
6767
var includeGeneratedArg = new Arg("IncludeGenerated", "--include-generated", "bool?", "Formats files generated by the SDK.");
6868
var binaryLogArg = new Arg("BinaryLog", "--binarylog", "string", "Logs all project or solution load information to a binary log file.");
6969
var reportArg = new Arg("Report", "--report", "string", "Produces a JSON report in the specified directory.");
70-
var formatDiagnosticsArg = new Arg("Diagnostics", "--diagnostics", "IEnumerable<string>", "A list of diagnostic IDs to use as a filter when fixing code style or third-party issues. Default value is whichever IDs are listed in the .editorconfig file. For a list of built-in analyzer rule IDs that you can specify, see the list of IDs for code-analysis style rules.") {IsCollection = true, CollectionSeparator = " "};
70+
var formatDiagnosticsArg = new Arg("Diagnostics", "--diagnostics", "IEnumerable<string>", "A list of diagnostic IDs to use as a filter when fixing code style or third-party issues. Default value is whichever IDs are listed in the .editorconfig file. For a list of built-in analyzer rule IDs that you can specify, see the list of IDs for code-analysis style rules.") {IsCollection = true, Separator = " "};
7171

7272
var commands = new Command[]
7373
{
@@ -1244,7 +1244,7 @@ using Internal;
12441244
["test", "$Project"],
12451245
[
12461246
propsArg,
1247-
new Arg("Environments", "--environment", "IEnumerable<(string name, string value)>", "Sets the value of an environment variable. Creates the variable if it does not exist, overrides if it does exist. Use of this option will force the tests to be run in an isolated process.") { IsCollection = true, CollectionSeparator = "="},
1247+
new Arg("Environments", "--environment", "IEnumerable<(string name, string value)>", "Sets the value of an environment variable. Creates the variable if it does not exist, overrides if it does exist. Use of this option will force the tests to be run in an isolated process.") { IsCollection = true, Separator = "="},
12481248
new Arg("Loggers", "--logger ", "IEnumerable<string>", "Specifies a logger for test results and optionally switches for the logger.") { IsCollection = true },
12491249
projectArg with { Comments = "Path to the test project.<br/>Or path to the solution.<br/>Or path to a directory that contains a project or a solution.<br/>Or path to a test project .dll file.<br/>Or path to a test project .exe file.<br/>If not specified, the effect is the same as using the DIRECTORY argument to specify the current directory." },
12501250
new Arg("TestAdapterPath", "--test-adapter-path", "string", "Path to a directory to be searched for additional test adapters. Only .dll files with suffix .TestAdapter.dll are inspected. If not specified, the directory of the test .dll is searched.") { AddArgOverride = ".AddArgs(\"--test-adapter-path\", $\"{string.Join(\";\", new[] {TestAdapterPath, virtualContext.Resolve(settings.DotNetVSTestLoggerDirectory)}.Where(i => !string.IsNullOrWhiteSpace(i)))}\")" } ,
@@ -1272,7 +1272,8 @@ using Internal;
12721272
new Arg("Settings", "--settings", "string", "The .runsettings file to use for running the tests. The TargetPlatform element (x86|x64) has no effect for dotnet test. To run tests that target x86, install the x86 version of .NET Core. The bitness of the dotnet.exe that is on the path is what will be used for running tests."),
12731273
new Arg("ListTests", "--list-tests", "bool?", "List the discovered tests instead of running the tests."),
12741274
verbosityArg,
1275-
diagnosticsArg
1275+
diagnosticsArg,
1276+
terminalLoggerArg
12761277
],
12771278
CommandTypes.Build | CommandTypes.Test | CommandTypes.RequiresSettings
12781279
),
@@ -1827,7 +1828,7 @@ public partial record <#= command.Name #>(
18271828
foreach (var arg in command.Args.Where(i => !i.IsProject).Where(i => i.IsCollection && i.ArgName != "--property"))
18281829
{
18291830
#>
1830-
.AddArgs(<#= arg.PropertyName #>.ToArgs("<#= arg.ArgName #>", "<#= arg.CollectionSeparator #>"))
1831+
.AddArgs(<#= arg.PropertyName #>.ToArgs("<#= arg.ArgName #>", "<#= arg.Separator #>"))
18311832
<#
18321833
}
18331834

@@ -1836,7 +1837,7 @@ public partial record <#= command.Name #>(
18361837
if (string.IsNullOrWhiteSpace(arg.AddArgOverride))
18371838
{
18381839
#>
1839-
.AddArgs(<#= arg.PropertyName #>.ToArgs("<#= arg.ArgName #>", "<#= arg.CollectionSeparator #>"))
1840+
.AddArgs(<#= arg.PropertyName #>.ToArgs("<#= arg.ArgName #>", "<#= arg.Separator #>"))
18401841
<#
18411842
}
18421843
else
@@ -1886,7 +1887,7 @@ public partial record <#= command.Name #>(
18861887
public string Comments { get; set; } = Comments;
18871888
public bool IsProject { get; set; }
18881889
public bool IsCollection { get; set; }
1889-
public string CollectionSeparator { get; set; } = "";
1890+
public string Separator { get; set; } = "";
18901891
public string DefaultValue { get; set; }
18911892
public string AddArgOverride { get; set; }
18921893
}

CSharpInteractive.HostApi/DotNetTerminalLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ public enum DotNetTerminalLogger
1919
/// <summary>
2020
/// Skips the environment check and uses the default console logger.
2121
/// </summary>
22-
Off
22+
Off
2323
}

CSharpInteractive.HostApi/Internal/DotNet/DotNetCommandLineExtensions.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ public static CommandLine AddMSBuildLoggers(this CommandLine cmd, IHost host, Do
8383
.AddProps("-p",
8484
("VSTestLogger", TeamcityLoggerName),
8585
("VSTestTestAdapterPath", virtualContext.Resolve(settings.DotNetVSTestLoggerDirectory)),
86-
("VSTestVerbosity", (verbosity.HasValue ? (verbosity.Value >= DotNetVerbosity.Normal ? verbosity.Value : DotNetVerbosity.Normal) : DotNetVerbosity.Normal).ToString().ToLowerInvariant()))
86+
("VSTestVerbosity", (verbosity.HasValue ? (verbosity.Value >= DotNetVerbosity.Normal ? verbosity.Value : DotNetVerbosity.Normal) : DotNetVerbosity.Normal).ToString().ToLowerInvariant()),
87+
("TestingPlatformDotnetTestSupport", "false"))
8788
.AddVars(("TEAMCITY_SERVICE_MESSAGES_PATH", virtualContext.Resolve(settings.TeamCityMessagesPath)))
8889
: cmd;
8990
}
@@ -146,26 +147,25 @@ public static string[] ToArgs<T>(this T value, string name, string collectionSep
146147
{
147148
if (!string.IsNullOrWhiteSpace(collectionSeparator))
148149
{
149-
return [$"{name}{collectionSeparator}\"{value}\""];
150+
return [$"{name}{collectionSeparator}{value}"];
150151
}
151152

152153
var valueStr = value?.ToString();
153154
return string.IsNullOrWhiteSpace(valueStr) ? [] : [name, valueStr!];
154155
}
155156

157+
public static string[] ToArgs<T>(this IEnumerable<(string name, T value) > values, string name, string separator)
158+
{
159+
return values.SelectMany(i => new [] { name, $"{i.name}{separator}{i.value}"}).ToArray();
160+
}
161+
156162
public static string[] ToArgs(this IEnumerable<string> values, string name, string collectionSeparator)
157163
{
158164
if (string.IsNullOrEmpty(collectionSeparator))
159165
{
160166
return values.SelectMany(value => string.IsNullOrWhiteSpace(value) ? [] : new[] {name, value}).ToArray();
161167
}
162-
163-
if (string.IsNullOrWhiteSpace(collectionSeparator))
164-
{
165-
var result = Enumerable.Repeat(name, 1).Concat(values).ToArray();
166-
return result.Length > 1 ? result : [];
167-
}
168-
168+
169169
var str = string.Join(collectionSeparator, values);
170170
if (string.IsNullOrWhiteSpace(str))
171171
{

0 commit comments

Comments
 (0)