Fixed issue where SolutionName variable could go missing. Added comments
This commit is contained in:
Родитель
a52c3ec076
Коммит
c597775169
|
@ -352,4 +352,5 @@ MigrationBackup/
|
|||
.ionide/
|
||||
|
||||
# Ignored as part of the Labs builds process
|
||||
Common/Labs.TargetFrameworks.props*
|
||||
Common/Labs.TargetFrameworks.props*
|
||||
Common/Scripts/UpdateTargetFrameworks.CurrentVariant.*
|
|
@ -5,6 +5,10 @@
|
|||
<DisableFastUpToDateCheck>True</DisableFastUpToDateCheck>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="CleanupConditionalTargetFrameworkCache" BeforeTargets="Clean">
|
||||
<Delete Files="$(RepositoryDirectory)Common/Scripts/UpdateTargetFrameworks.CurrentVariant.txt" />
|
||||
</Target>
|
||||
|
||||
<Target Name="PruneExtraTargetFrameworks" BeforeTargets="PreBuildEvent">
|
||||
<PropertyGroup>
|
||||
<PowerShellCommand Condition=" '$(OS)' == 'Windows_NT' ">powershell</PowerShellCommand>
|
||||
|
@ -19,4 +23,4 @@
|
|||
|
||||
<Exec Command="$(PowerShellCommand) -ExecutionPolicy Unrestricted -NoProfile -File $(RepositoryDirectory)Common/Scripts/UpdateTargetFrameworks.ps1 $(LabsTargetPlatformsVariant) --Verbose" WorkingDirectory="$(RepositoryDirectory)Common/Scripts/" />
|
||||
</Target>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
# This file can execute in parallel, causing potential file access issues.
|
||||
# This lock prevent us from reading or writing concurrently and getting access exceptions.
|
||||
if (Test-Path ".\..\Labs.TargetFrameworks.props.lock") {
|
||||
return;
|
||||
}
|
||||
|
@ -9,6 +11,17 @@ if ($args.Length -eq 0 -or ![bool]$args[0]) {
|
|||
|
||||
$variant = $args[0];
|
||||
|
||||
# MSBuild uses the SolutionName to determine the variant, but SolutionName occassionally goes missing during
|
||||
# the build process, which causes the default/fallback variant to be used when it shouldn't.
|
||||
# This check ensures we're always using the same variant, until the file is deleted by MSBuild during a clean.
|
||||
if ((Get-Content -Path .\UpdateTargetFrameworks.CurrentVariant.txt).Trim() -notlike $variant) {
|
||||
# for debug only
|
||||
Set-Content -Path .\UpdateTargetFrameworks.CircumventedVariant.$variant.txt -Value '';
|
||||
return;
|
||||
}
|
||||
|
||||
Set-Content -Path .\UpdateTargetFrameworks.CurrentVariant.txt -Value $variant;
|
||||
|
||||
Set-Content -Path .\..\Labs.TargetFrameworks.props.lock -Value '';
|
||||
$fileContents = Get-Content -Path .\..\Labs.TargetFrameworks.default.props
|
||||
|
||||
|
@ -20,20 +33,19 @@ if ($variant -eq "All") {
|
|||
if ($variant -eq "Wasm") {
|
||||
# Remove all non-wasm TFMs
|
||||
$newFileContents = $fileContents -replace '<(UwpTargetFramework|WinAppSdkTargetFramework|WpfLibTargetFramework|LinuxLibTargetFramework|AndroidLibTargetFramework|MacOSLibTargetFramework|iOSLibTargetFramework)>.+?>', '';
|
||||
Set-Content -Path .\..\Labs.TargetFrameworks.props.wasmonly -Value '';
|
||||
}
|
||||
|
||||
if ($variant -eq "Windows") {
|
||||
# Minimal Windows dependencies.
|
||||
$newFileContents = $fileContents -replace '<(LinuxLibTargetFramework|AndroidLibTargetFramework|MacOSLibTargetFramework|iOSLibTargetFramework)>.+?>', '';
|
||||
Set-Content -Path .\..\Labs.TargetFrameworks.props.windowsonly -Value '';
|
||||
}
|
||||
|
||||
# MSBuild uses last modified date instead of file hashes to determine when the content has changed.
|
||||
# Only update the props file if the new content is different.
|
||||
if ($newFileContents -eq $fileContents) {
|
||||
Remove-Item -Path .\..\Labs.TargetFrameworks.props.lock;
|
||||
return;
|
||||
}
|
||||
|
||||
Set-Content -Force -Path .\..\Labs.TargetFrameworks.props -Value $newFileContents;
|
||||
|
||||
Remove-Item -Path .\..\Labs.TargetFrameworks.props.lock;
|
||||
Remove-Item -Path .\..\Labs.TargetFrameworks.props.lock;
|
||||
|
|
Загрузка…
Ссылка в новой задаче