Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit559bb41

Browse files
[tests] We must set 'UseFloatingTargetPlatformVersion=true' for our test projects, to avoid building them with other workloads than the current workload. (#24281)
Also the ComputeRemoteGeneratorProperties task needs to know the value ofUseFloatingTargetPlatformVersion, so that it can be passed on when executing`dotnet` to compute binding variables, because otherwise we might end up withvariables from the wrong workload.---------Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parentfa0bc12 commit559bb41

File tree

7 files changed

+40
-21
lines changed

7 files changed

+40
-21
lines changed

‎msbuild/Xamarin.MacDev.Tasks/Tasks/ComputeRemoteGeneratorProperties.cs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ public class ComputeRemoteGeneratorProperties : XamarinTask, ITaskCallback, ICan
2121

2222
publicstringTargetFrameworkIdentifier{get;set;}=string.Empty;
2323

24+
publicstringUseFloatingTargetPlatformVersion{get;set;}=string.Empty;
25+
2426
// Outputs
2527
[Output]
2628
publicstringBaseLibDllPath{get;set;}=string.Empty;
@@ -88,6 +90,8 @@ void ComputeProperties ()
8890
arguments.Add("/t:_WriteRemoteGeneratorProperties");
8991
if(!string.IsNullOrEmpty(TargetFrameworkIdentifier))
9092
arguments.Add($"/p:TargetFrameworkIdentifier={TargetFrameworkIdentifier}");
93+
if(!string.IsNullOrEmpty(UseFloatingTargetPlatformVersion))
94+
arguments.Add($"/p:UseFloatingTargetPlatformVersion={UseFloatingTargetPlatformVersion}");
9195
arguments.Add($"/p:_PlatformName={PlatformName}");
9296
arguments.Add($"/bl:{binlog}");
9397

‎msbuild/Xamarin.Shared/Xamarin.Shared.targets‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1983,6 +1983,7 @@ Copyright (C) 2018 Microsoft. All rights reserved.
19831983
Condition="'$(IsMacEnabled)' == 'true' And '$(BindingProjectBuildSessionId)' != ''"
19841984
IntermediateOutputPath="$(IntermediateOutputPath)"
19851985
TargetFrameworkMoniker="$(_ComputedTargetFrameworkMoniker)"
1986+
UseFloatingTargetPlatformVersion="$(UseFloatingTargetPlatformVersion)"
19861987
>
19871988
<OutputTaskParameter="BaseLibDllPath"PropertyName="BaseLibDllPath" />
19881989
<OutputTaskParameter="BGenToolExe"PropertyName="BGenToolExe" />

‎tests/common/shared-dotnet.csproj‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
<NoWarnCondition="'$(IncludeCS1416Warnigs)' != 'true'">CA1416;$(NoWarn)</NoWarn>
6262

6363
<CustomBeforeMicrosoftCommonTargets>$(CustomBeforeMicrosoftCommonTargets);$(MSBuildThisFileDirectory)SupportedOSPlatformVersions.targets</CustomBeforeMicrosoftCommonTargets>
64+
65+
<!-- We must set 'UseFloatingTargetPlatformVersion=true' for our test projects, to avoid building them with other workloads than the current workload.-->
66+
<UseFloatingTargetPlatformVersionCondition="'$(UseFloatingTargetPlatformVersion)' == ''">true</UseFloatingTargetPlatformVersion>
6467
</PropertyGroup>
6568

6669
<ItemGroup>

‎tests/dotnet/UnitTests/ProjectTest.cs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ public void BuildMyClassLibrary (ApplePlatform platform)
103103
varproject_path=GetProjectPath(project,platform:platform);
104104
Clean(project_path);
105105
varproperties=GetDefaultProperties();
106+
properties.Remove("UseFloatingTargetPlatformVersion");// This test verifies that we use the correct workload to build library projects, so we can't use a floating TPF version.
106107
varresult=DotNet.AssertBuild(project_path,properties);
107108
Assert.That(result.StandardOutput.ToString(),Does.Not.Contain("Task\"ILLink\""),"Linker executed unexpectedly.");
108109

‎tests/dotnet/UnitTests/TemplateTest.cs‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,8 @@ public void CreateAndBuildProjectTemplate (TemplateInfo info)
218218
varoutputDir=Path.Combine(tmpDir,info.Template);
219219
DotNet.AssertNew(outputDir,info.Template,language:language.AsLanguageIdentifier());
220220
varproj=Path.Combine(outputDir,$"{info.Template}.{language.AsFileExtension()}");
221-
varrv=DotNet.AssertBuild(proj);
221+
varproperties=GetDefaultProperties();
222+
varrv=DotNet.AssertBuild(proj,properties);
222223
varwarnings=BinLog.GetBuildLogWarnings(rv.BinLogPath).Select(v=>v.Message);
223224
Assert.That(warnings,Is.Empty,$"Build warnings:\n\t{string.Join("\n\t",warnings)}");
224225

@@ -232,7 +233,7 @@ public void CreateAndBuildProjectTemplate (TemplateInfo info)
232233
InsertCodeToExitAppAfterLaunch(language,outputDir);
233234

234235
// Build the sample
235-
rv=DotNet.AssertBuild(proj);
236+
rv=DotNet.AssertBuild(proj,properties);
236237

237238
// There should still not be any warnings
238239
warnings=BinLog.GetBuildLogWarnings(rv.BinLogPath).Select(v=>v.Message);
@@ -277,7 +278,8 @@ bool IsMatching (TemplateLanguage lang, TemplateLanguage? value)
277278
DotNet.AssertNew(outputDir,item.Template,"item_"+item.Template,language:language.AsLanguageIdentifier());
278279

279280
varproj=Path.Combine(outputDir,$"{info.Template}.{language.AsFileExtension()}");
280-
varrv=DotNet.AssertBuild(proj);
281+
varproperties=GetDefaultProperties();
282+
varrv=DotNet.AssertBuild(proj,properties);
281283
varwarnings=BinLog.GetBuildLogWarnings(rv.BinLogPath).Select(v=>v.Message);
282284
Assert.That(warnings,Is.Empty,$"Build warnings:\n\t{string.Join("\n\t",warnings)}");
283285

@@ -290,7 +292,7 @@ bool IsMatching (TemplateLanguage lang, TemplateLanguage? value)
290292
InsertCodeToExitAppAfterLaunch(language,outputDir);
291293

292294
// Build the sample
293-
rv=DotNet.AssertBuild(proj);
295+
rv=DotNet.AssertBuild(proj,properties);
294296

295297
// There should still not be any warnings
296298
warnings=BinLog.GetBuildLogWarnings(rv.BinLogPath).Select(v=>v.Message);

‎tests/dotnet/UnitTests/TestBaseClass.cs‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ protected static Dictionary<string, string> GetDefaultProperties (string? runtim
4343
if(includeRemoteProperties==true)
4444
AddRemoteProperties(rv);
4545

46+
// We must set 'UseFloatingTargetPlatformVersion=true' for our test projects, to avoid building them with other workloads than the current workload.
47+
rv["UseFloatingTargetPlatformVersion"]="true";
48+
4649
returnrv;
4750
}
4851

‎tests/dotnet/UnitTests/XcodeProjectTests.cs‎

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,8 @@ public void BuildAppiOS (string projConfig, string rid)
5959
{"SchemeName",xcodeProjName},
6060
});
6161

62-
varprojProps=newDictionary<string,string>{
63-
{"Configuration",projConfig},
64-
{"RuntimeIdentifier",rid},
65-
};
62+
varprojProps=GetDefaultProperties(runtimeIdentifiers:rid);
63+
projProps["Configuration"]=projConfig;
6664
DotNet.AssertBuild(proj,properties:projProps);
6765
varappDir=Path.Combine(testDir,"bin",projConfig,platform.ToFramework(),rid,$"{TestName}.app");
6866
Assert.That(appDir,Does.Exist,$"Expected app dir '{appDir}' did not exist.");
@@ -96,9 +94,8 @@ public void BuildBindingiOS (string projConfig, string fxConfig, bool createNati
9694
{"SchemeName",xcodeProjName},
9795
});
9896

99-
varprojProps=newDictionary<string,string>{
100-
{"Configuration",projConfig},
101-
};
97+
varprojProps=GetDefaultProperties();
98+
projProps["Configuration"]=projConfig;
10299
DotNet.AssertBuild(proj,properties:projProps);
103100
stringexpectedXcodeFxOutput;
104101
if(UsesCompressedBindingResourcePackage(platform)){
@@ -151,7 +148,8 @@ public class Binding
151148
";
152149
File.WriteAllText(Path.Combine(testDir,"Binding.cs"),classContent);
153150

154-
varrv=DotNet.AssertBuild(proj);
151+
varproperties=GetDefaultProperties();
152+
varrv=DotNet.AssertBuild(proj,properties);
155153
varwarnings=BinLog.GetBuildLogWarnings(rv.BinLogPath).Select(v=>v.Message);
156154
Assert.That(warnings,Is.Empty,$"Build warnings:\n\t{string.Join("\n\t",warnings)}");
157155
AssertXcFrameworkOutput(platform,testDir,xcodeProjName);
@@ -179,7 +177,8 @@ public void PackBinding (ApplePlatform platform)
179177
{"SchemeName",xcodeProjName},
180178
});
181179

182-
DotNet.AssertPack(proj);
180+
varproperties=GetDefaultProperties();
181+
DotNet.AssertPack(proj,properties);
183182
varexpectedNupkgOutput=Path.Combine(testDir,"bin","Release",$"{TestName}.1.0.0.nupkg");
184183
Assert.That(expectedNupkgOutput,Does.Exist,$"Expected pack output '{expectedNupkgOutput}' did not exist.");
185184

@@ -217,7 +216,8 @@ public void BuildIncremental (ApplePlatform platform)
217216
});
218217

219218
// Build the first time
220-
varrv=DotNet.AssertBuild(proj);
219+
varproperties=GetDefaultProperties();
220+
varrv=DotNet.AssertBuild(proj,properties);
221221
varallTargets=BinLog.GetAllTargets(rv.BinLogPath);
222222
AssertTargetExecuted(allTargets,"_BuildXcodeProjects","First _BuildXcodeProjects");
223223
varexpectedXcodeFxOutput=Path.Combine(testDir,"bin","Debug",platform.ToFramework(),$"{TestName}.resources",$"{xcodeProjName}{platform.AsString().ToLower()}.xcframework");
@@ -227,7 +227,7 @@ public void BuildIncremental (ApplePlatform platform)
227227
varoutputFxFirstWriteTime=File.GetLastWriteTime(expectedXcodeFxOutput);
228228

229229
// Build again, _BuildXcodeProjects should be skipped and outputs should not be updated
230-
rv=DotNet.AssertBuild(proj);
230+
rv=DotNet.AssertBuild(proj,properties);
231231
allTargets=BinLog.GetAllTargets(rv.BinLogPath);
232232
AssertTargetNotExecuted(allTargets,"_BuildXcodeProjects","Second _BuildXcodeProjects");
233233
Assert.That(expectedXcodeFxOutput,Does.Exist,$"Expected xcframework output '{expectedXcodeFxOutput}' did not exist.");
@@ -236,7 +236,7 @@ public void BuildIncremental (ApplePlatform platform)
236236

237237
// Update xcode project, _BuildXcodeProjects should run and outputs should be updated
238238
File.SetLastWriteTime(Path.Combine(xcodeProjPath,"project.pbxproj"),DateTime.Now);
239-
rv=DotNet.AssertBuild(proj);
239+
rv=DotNet.AssertBuild(proj,properties);
240240
allTargets=BinLog.GetAllTargets(rv.BinLogPath);
241241
AssertTargetExecuted(allTargets,"_BuildXcodeProjects","Third _BuildXcodeProjects");
242242
Assert.That(expectedXcodeFxOutput,Does.Exist,$"Expected xcframework output '{expectedXcodeFxOutput}' did not exist.");
@@ -269,7 +269,8 @@ public void BuildMultipleSchemesiOS ()
269269
{"SchemeName",secondSchemeName},
270270
});
271271

272-
DotNet.AssertBuild(proj);
272+
varproperties=GetDefaultProperties();
273+
DotNet.AssertBuild(proj,properties);
273274
AssertXcFrameworkOutput(platform,testDir,xcodeProjName);
274275
AssertXcFrameworkOutput(platform,testDir,secondSchemeName);
275276
}
@@ -302,7 +303,8 @@ public void BuildMultipleProjectsiOS ()
302303
{"SchemeName",xcodeProjName2},
303304
});
304305

305-
DotNet.AssertBuild(proj);
306+
varproperties=GetDefaultProperties();
307+
DotNet.AssertBuild(proj,properties);
306308
AssertXcFrameworkOutput(platform,testDir,xcodeProjName);
307309
AssertXcFrameworkOutput(platform,testDir,xcodeProjName2);
308310
}
@@ -332,7 +334,8 @@ public void BuildMultiTargeting ()
332334
{"SchemeName",xcodeProjName},
333335
});
334336

335-
DotNet.AssertBuild(proj);
337+
varproperties=GetDefaultProperties();
338+
DotNet.AssertBuild(proj,properties);
336339
foreach(varplatforminenabledPlatforms){
337340
AssertXcFrameworkOutput(platform,testDir,xcodeProjName);
338341
}
@@ -355,7 +358,8 @@ public void InvalidItemErroriOS ()
355358
{"SchemeName",xcodeProjName},
356359
});
357360

358-
varrv=DotNet.AssertBuildFailure(proj);
361+
varproperties=GetDefaultProperties();
362+
varrv=DotNet.AssertBuildFailure(proj,properties);
359363
varerrors=BinLog.GetBuildLogErrors(rv.BinLogPath).ToArray();
360364
varexpectedError=$"The Xcode project item: '{invalidXcodeProjPath}' could not be found. Please update the 'Include' value to a path containing a valid '.xcodeproj' file.";
361365
AssertErrorMessages(errors,expectedError);
@@ -382,7 +386,8 @@ public void InvalidSchemeErroriOS ()
382386
{"SchemeName",invaldSchemeName},
383387
});
384388

385-
varrv=DotNet.AssertBuildFailure(proj);
389+
varproperties=GetDefaultProperties();
390+
varrv=DotNet.AssertBuildFailure(proj,properties);
386391
varexpectedErrorContent=$"xcodebuild: error: The project named\"{xcodeProjName}\" does not contain a scheme named\"{invaldSchemeName}\".";
387392
varerrors=BinLog.GetBuildLogErrors(rv.BinLogPath).ToArray();
388393
AssertErrorMessages(errors,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp