Skip to content

Commit f6fe3a0

Browse files
authored
Merge branch 'release/9.0.3xx' into merge/release/9.0.1xx-to-release/9.0.3xx
2 parents 2652983 + cb70723 commit f6fe3a0

File tree

10 files changed

+114
-11
lines changed

10 files changed

+114
-11
lines changed

azure-pipelines-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ stages:
5151
enablePublishTestResults: true
5252
enablePublishBuildAssets: true
5353
enablePublishUsingPipelines: ${{ variables._PublishUsingPipelines }}
54-
enableSourceBuild: true
54+
enableSourceBuild: false
5555
sourceBuildParameters:
5656
enableInternalSources: true
5757
enableTelemetry: true

azure-pipelines.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ extends:
8181
enablePublishTestResults: true
8282
enablePublishBuildAssets: true
8383
enablePublishUsingPipelines: ${{ variables._PublishUsingPipelines }}
84-
enableSourceBuild: true
84+
enableSourceBuild: false
8585
publishAssetsImmediately: true
8686
sourceBuildParameters:
8787
enableInternalSources: true

eng/Version.Details.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
<Dependencies>
33
<ProductDependencies>
44
<!-- Intermediate is necessary for source build. -->
5-
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="9.0.0-alpha.1.24575.1">
5+
<Dependency Name="Microsoft.SourceBuild.Intermediate.source-build-externals" Version="9.0.0-alpha.1.24515.2">
66
<Uri>https://github.com/dotnet/source-build-externals</Uri>
7-
<Sha>ab469606a3e6b026dcac301e2dab96117c94faeb</Sha>
7+
<Sha>659bf534d9fbf673493b821be99df12032277549</Sha>
88
<SourceBuild RepoName="source-build-externals" ManagedOnly="true" />
99
</Dependency>
1010
<!-- Intermediate is necessary for source build. -->

eng/Versions.props

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
<Project>
22
<PropertyGroup>
3-
<VersionPrefix>9.0.112</VersionPrefix>
3+
<VersionPrefix>9.0.307</VersionPrefix>
44
<!-- When StabilizePackageVersion is set to 'true', this branch will produce stable outputs for 'Shipping' packages -->
55
<StabilizePackageVersion Condition="'$(StabilizePackageVersion)' == ''">true</StabilizePackageVersion>
66
<DotNetFinalVersionKind Condition="'$(StabilizePackageVersion)' == 'true'">release</DotNetFinalVersionKind>
77
<!-- Calculate prerelease label -->
8-
<PreReleaseVersionLabel Condition="'$(StabilizePackageVersion)' != 'true'">rtm</PreReleaseVersionLabel>
8+
<PreReleaseVersionLabel Condition="'$(StabilizePackageVersion)' != 'true'">preview</PreReleaseVersionLabel>
99
<PreReleaseVersionLabel Condition="'$(StabilizePackageVersion)' == 'true' and $(VersionPrefix.EndsWith('00'))">rtm</PreReleaseVersionLabel>
1010
<PreReleaseVersionLabel Condition="'$(StabilizePackageVersion)' == 'true' and !$(VersionPrefix.EndsWith('00'))">servicing</PreReleaseVersionLabel>
1111
<PreReleaseVersionIteration Condition="'$(StabilizePackageVersion)' != 'true'">

src/Microsoft.TemplateEngine.Edge/Constraints/WorkloadConstraintFactory.cs

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ namespace Microsoft.TemplateEngine.Edge.Constraints
1111
{
1212
public sealed class WorkloadConstraintFactory : ITemplateConstraintFactory
1313
{
14+
private static readonly SemaphoreSlim Mutex = new(1);
15+
1416
Guid IIdentifiedComponent.Id { get; } = Guid.Parse("{F8BA5B13-7BD6-47C8-838C-66626526817B}");
1517

1618
string ITemplateConstraintFactory.Type => "workload";
@@ -97,8 +99,17 @@ private static IEnumerable<string> ParseArgs(string? args)
9799
}
98100

99101
token.ThrowIfCancellationRequested();
100-
IEnumerable<WorkloadInfo> currentProviderWorkloads = await providers[0].GetInstalledWorkloadsAsync(token).ConfigureAwait(false);
101-
workloads = currentProviderWorkloads.ToList();
102+
103+
await Mutex.WaitAsync(token).ConfigureAwait(false);
104+
try
105+
{
106+
IEnumerable<WorkloadInfo> currentProviderWorkloads = await providers[0].GetInstalledWorkloadsAsync(token).ConfigureAwait(false);
107+
workloads = currentProviderWorkloads.ToList();
108+
}
109+
finally
110+
{
111+
Mutex.Release();
112+
}
102113

103114
if (workloads.Select(w => w.Id).HasDuplicates(StringComparer.InvariantCultureIgnoreCase))
104115
{

src/Microsoft.TemplateEngine.Orchestrator.RunnableProjects/ParameterConverter.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ private static bool TryResolveChoiceValue(string? literal, ITemplateParameter pa
188188
}
189189

190190
string? partialMatch = null;
191+
bool multiplePartialMatches = false;
191192

192193
foreach (string choiceValue in param.Choices.Keys)
193194
{
@@ -205,13 +206,19 @@ private static bool TryResolveChoiceValue(string? literal, ITemplateParameter pa
205206
}
206207
else
207208
{
208-
// multiple partial matches, can't take one.
209-
match = null;
210-
return false;
209+
// Multiple partial matches, keep searching for exact match, fail if we don't find one
210+
// because we don't know which partial match we should select.
211+
multiplePartialMatches = true;
211212
}
212213
}
213214
}
214215

216+
if (multiplePartialMatches)
217+
{
218+
match = null;
219+
return false;
220+
}
221+
215222
match = partialMatch;
216223
return match != null;
217224
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace ConsoleApp
2+
{
3+
internal class Program
4+
{
5+
static void Main(string[] args)
6+
{
7+
Console.WriteLine("User's choice is: aa.");
8+
}
9+
}
10+
}

test/Microsoft.TemplateEngine.Orchestrator.RunnableProjects.UnitTests/SnapshotTests.cs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,35 @@ public Task TestTemplateWithCircleDependencyInMacros()
273273
VerificationEngine engine = new VerificationEngine(_log);
274274
return engine.Execute(options);
275275
}
276+
277+
[Fact]
278+
public Task TestSelectionForMultiChoicesWhenThereAreMultiplePartialMatchesAndOnePreciseMatch()
279+
{
280+
string templateLocation = GetTestTemplateLocation("TemplateWithMultipleChoicesAndPartialMatches");
281+
var templateParams = new Dictionary<string, string?>()
282+
{
283+
// There are multiple choices for the parameter that overlap: "aab", "aac", "aa".
284+
// We want to ensure that "aa" can be selected, because it is a precise match,
285+
// even if there are more than one choices that start with "aa", and even if "aa",
286+
// is not listed first in the list of choices.
287+
{ "tests", "aa" }
288+
};
289+
string workingDir = TestUtils.CreateTemporaryFolder();
290+
291+
TemplateVerifierOptions options =
292+
new TemplateVerifierOptions(templateName: "TestAssets.TemplateWithMultipleChoicesAndPartialMatches")
293+
{
294+
TemplatePath = templateLocation,
295+
OutputDirectory = workingDir,
296+
DoNotAppendTemplateArgsToScenarioName = true,
297+
DoNotPrependTemplateNameToScenarioName = true,
298+
SnapshotsDirectory = "Approvals"
299+
}
300+
.WithInstantiationThroughTemplateCreatorApi(templateParams);
301+
302+
VerificationEngine engine = new VerificationEngine(_log);
303+
return engine.Execute(options);
304+
}
276305
}
277306
}
278307

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"$schema": "https://json.schemastore.org/template.json",
3+
"author": "Test Asset",
4+
"classifications": [ "Test Asset" ],
5+
"name": "TemplateWithMultipleChoicesAndPartialMatches",
6+
"tags": { "type": "project" },
7+
"generatorVersions": "[1.0.0.0-*)",
8+
"groupIdentity": "TestAssets.TemplateWithMultipleChoicesAndPartialMatches",
9+
"precedence": "100",
10+
"identity": "TestAssets.TemplateWithMultipleChoicesAndPartialMatches",
11+
"shortName": "TestAssets.TemplateWithMultipleChoicesAndPartialMatches",
12+
"symbols": {
13+
"tests": {
14+
"displayName": "Tests",
15+
"type": "parameter",
16+
"datatype": "choice",
17+
"replaces": "user_selectedtests",
18+
"allowMultipleValues": true,
19+
"enableQuotelessLiterals": true,
20+
"choices": [
21+
{
22+
"choice": "aab",
23+
"displayName": "aab"
24+
},
25+
{
26+
"choice": "aaa",
27+
"displayName": "aaa"
28+
},
29+
{
30+
"choice": "aa",
31+
"displayName": "aa"
32+
}
33+
]
34+
}
35+
}
36+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace ConsoleApp
2+
{
3+
internal class Program
4+
{
5+
static void Main(string[] args)
6+
{
7+
Console.WriteLine("User's choice is: user_selectedtests.");
8+
}
9+
}
10+
}

0 commit comments

Comments
 (0)