Skip to content

Commit 16b1c61

Browse files
authored
Merge branch 'main' into darc-main-dfdd07c8-a19b-4a2f-97c3-11cae5af91fc
2 parents 925bd82 + fa2361b commit 16b1c61

File tree

106 files changed

+2260
-862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

106 files changed

+2260
-862
lines changed

.config/dotnet-tools.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"isRoot": true,
44
"tools": {
55
"microsoft.dotnet.darc": {
6-
"version": "1.1.0-beta.25305.3",
6+
"version": "1.1.0-beta.25312.2",
77
"commands": [
88
"darc"
99
]

documentation/general/dotnet-run-file.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ The command takes a path which can be either
4747
## Target path
4848

4949
The path passed to `dotnet run ./some/path.cs` is called *the target path*.
50-
The target path must be a file which has the `.cs` file extension.
50+
The target path must be a file which either has the `.cs` file extension,
51+
or a file whose contents start with `#!`.
5152
*The target directory* is the directory of the target file.
5253

5354
## Integration into the existing `dotnet run` command
@@ -57,7 +58,7 @@ specifically `file.cs` is passed as the first command-line argument to the targe
5758
We preserve this behavior to avoid a breaking change.
5859
The file-based build and run kicks in only when:
5960
- a project file cannot be found (in the current directory or via the `--project` option), and
60-
- if the target file exists and has the `.cs` file extension.
61+
- if the target file exists, and has the `.cs` file extension or contents that start with `#!`.
6162

6263
File-based programs are processed by `dotnet run` equivalently to project-based programs unless specified otherwise in this document.
6364
For example, the remaining command-line arguments after the first argument (the target path) are passed through to the target app
@@ -86,6 +87,10 @@ other files in the target directory or its subdirectories are included in the co
8687
For example, other `.cs` files but also `.resx` (embedded resources).
8788
Similarly, implicit build files like `Directory.Build.props` or `Directory.Packages.props` are used during the build.
8889

90+
> [!CAUTION]
91+
> Multi-file support is postponed for .NET 11.
92+
> In .NET 10, only the single file passed as the command-line argument to `dotnet run` is part of the compilation.
93+
8994
### Nested files
9095

9196
If there are nested project files like
@@ -153,14 +158,15 @@ Other directives result in an error, reserving them for future use.
153158

154159
```cs
155160
#:sdk Microsoft.NET.Sdk.Web
156-
#:property TargetFramework net11.0
157-
#:property LangVersion preview
161+
#:property TargetFramework=net11.0
162+
#:property LangVersion=preview
158163
159164
```
160165

161-
The value must be separated from the name of the directive by white space (`@` is additionally allowed separator for the package directive)
166+
The value must be separated from the kind (`package`/`sdk`/`property`) of the directive by whitespace
162167
and any leading and trailing white space is not considered part of the value.
163-
Any value can optionally have two parts separated by a space (more whitespace characters could be allowed in the future).
168+
Any value can optionally have two parts separated by `@` in case of `package`/`sdk` or `=` in case of `property`
169+
and whitespace is trimmed from the two parts around the separator.
164170
The value of the first `#:sdk` is injected into `<Project Sdk="{0}">` with the separator (if any) replaced with `/`,
165171
and the subsequent `#:sdk` directive values are split by the separator and injected as `<Sdk Name="{0}" Version="{1}" />` elements (or without the `Version` attribute if there is no separator).
166172
It is an error if the first part (name) is empty (the version is allowed to be empty, but that results in empty `Version=""`).

eng/Version.Details.xml

Lines changed: 235 additions & 235 deletions
Large diffs are not rendered by default.

eng/Versions.props

Lines changed: 114 additions & 114 deletions
Large diffs are not rendered by default.

eng/common/core-templates/job/onelocbuild.yml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,7 @@ jobs:
8686
isAutoCompletePrSelected: ${{ parameters.AutoCompletePr }}
8787
${{ if eq(parameters.CreatePr, true) }}:
8888
isUseLfLineEndingsSelected: ${{ parameters.UseLfLineEndings }}
89-
${{ if eq(parameters.RepoType, 'gitHub') }}:
90-
isShouldReusePrSelected: ${{ parameters.ReusePr }}
89+
isShouldReusePrSelected: ${{ parameters.ReusePr }}
9190
packageSourceAuth: patAuth
9291
patVariable: ${{ parameters.CeapexPat }}
9392
${{ if eq(parameters.RepoType, 'gitHub') }}:
@@ -118,4 +117,4 @@ jobs:
118117
pathToPublish: '$(Build.SourcesDirectory)/eng/Localize/'
119118
publishLocation: Container
120119
artifactName: Loc
121-
condition: ${{ parameters.condition }}
120+
condition: ${{ parameters.condition }}

global.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414
}
1515
},
1616
"msbuild-sdks": {
17-
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25304.106",
18-
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25304.106",
17+
"Microsoft.DotNet.Arcade.Sdk": "10.0.0-beta.25311.102",
18+
"Microsoft.DotNet.Helix.Sdk": "10.0.0-beta.25311.102",
1919
"Microsoft.Build.NoTargets": "3.7.0",
2020
"Microsoft.Build.Traversal": "3.4.0"
2121
}

src/Cli/Microsoft.DotNet.Cli.Utils/Command.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77

88
namespace Microsoft.DotNet.Cli.Utils;
99

10-
public class Command(Process? process, bool trimTrailingNewlines = false) : ICommand
10+
public class Command(Process? process, bool trimTrailingNewlines = false, IDictionary<string, string?>? customEnvironmentVariables = null) : ICommand
1111
{
1212
private readonly Process _process = process ?? throw new ArgumentNullException(nameof(process));
1313

14+
private readonly Dictionary<string, string?>? _customEnvironmentVariables =
15+
// copy the dictionary to avoid mutating the original
16+
customEnvironmentVariables == null ? null : new(customEnvironmentVariables);
17+
1418
private StreamForwarder? _stdOut;
1519

1620
private StreamForwarder? _stdErr;
@@ -98,6 +102,7 @@ public ICommand WorkingDirectory(string? projectDirectory)
98102
public ICommand EnvironmentVariable(string name, string? value)
99103
{
100104
_process.StartInfo.Environment[name] = value;
105+
_customEnvironmentVariables?[name] = value;
101106
return this;
102107
}
103108

@@ -185,6 +190,14 @@ public ICommand OnErrorLine(Action<string> handler)
185190

186191
public string CommandArgs => _process.StartInfo.Arguments;
187192

193+
public ProcessStartInfo StartInfo => _process.StartInfo;
194+
195+
/// <summary>
196+
/// If set in the constructor, it's used to keep track of environment variables modified via <see cref="EnvironmentVariable"/>
197+
/// unlike <see cref="ProcessStartInfo.Environment"/> which includes all environment variables of the current process.
198+
/// </summary>
199+
public IReadOnlyDictionary<string, string?>? CustomEnvironmentVariables => _customEnvironmentVariables;
200+
188201
public ICommand SetCommandArgs(string commandArgs)
189202
{
190203
_process.StartInfo.Arguments = commandArgs;

src/Cli/dotnet/CliStrings.resx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
<value>More than one command is defined for the tool.</value>
318318
</data>
319319
<data name="ToolSettingsUnsupportedRunner" xml:space="preserve">
320-
<value>Command '{0}' uses unsupported runner '{1}'."</value>
320+
<value>Tool '{0}' uses unsupported runner '{1}'."</value>
321321
</data>
322322
<data name="ToolUnsupportedRuntimeIdentifier" xml:space="preserve">
323323
<value>The tool does not support the current architecture or operating system ({0}). Supported runtimes: {1}</value>
@@ -808,4 +808,7 @@ The default is 'false.' However, when targeting .NET 7 or lower, the default is
808808
<value>Cannot specify --version when the package argument already contains a version.</value>
809809
<comment>{Locked="--version"}</comment>
810810
</data>
811+
<data name="YesOptionDescription" xml:space="preserve">
812+
<value>Accept all confirmation prompts using "yes."</value>
813+
</data>
811814
</root>

src/Cli/dotnet/CommandFactory/CommandFactoryUsingResolver.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,6 @@ public static Command Create(CommandSpec commandSpec)
113113
StartInfo = psi
114114
};
115115

116-
return new Command(_process);
116+
return new Command(_process, customEnvironmentVariables: commandSpec.EnvironmentVariables);
117117
}
118118
}

src/Cli/dotnet/CommandFactory/CommandResolution/LocalToolsCommandResolver.cs

Lines changed: 3 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#nullable disable
55

6+
using Microsoft.DotNet.Cli.Commands.Tool;
67
using Microsoft.DotNet.Cli.ToolManifest;
78
using Microsoft.DotNet.Cli.ToolPackage;
89
using Microsoft.DotNet.Cli.Utils;
@@ -91,31 +92,8 @@ private CommandSpec GetPackageCommandSpecUsingMuxer(CommandResolverArguments arg
9192
toolCommandName.ToString()));
9293
}
9394

94-
if (toolCommand.Runner == "dotnet")
95-
{
96-
if (toolManifestPackage.RollForward || allowRollForward)
97-
{
98-
arguments.CommandArguments = ["--allow-roll-forward", .. arguments.CommandArguments];
99-
}
100-
101-
return MuxerCommandSpecMaker.CreatePackageCommandSpecUsingMuxer(
102-
toolCommand.Executable.Value,
103-
arguments.CommandArguments);
104-
}
105-
else if (toolCommand.Runner == "executable")
106-
{
107-
var escapedArgs = ArgumentEscaper.EscapeAndConcatenateArgArrayForProcessStart(
108-
arguments.CommandArguments);
109-
110-
return new CommandSpec(
111-
toolCommand.Executable.Value,
112-
escapedArgs);
113-
}
114-
else
115-
{
116-
throw new GracefulException(string.Format(CliStrings.ToolSettingsUnsupportedRunner,
117-
toolCommand.Name, toolCommand.Runner));
118-
}
95+
return ToolCommandSpecCreator.CreateToolCommandSpec(toolCommand.Name.Value, toolCommand.Executable.Value, toolCommand.Runner,
96+
toolManifestPackage.RollForward || allowRollForward, arguments.CommandArguments);
11997
}
12098
else
12199
{

0 commit comments

Comments
 (0)