Switch to powershell for updating target frameworks
This commit is contained in:
Родитель
293e7fc6bb
Коммит
02751dfb2c
|
@ -1,20 +1,14 @@
|
|||
<Project>
|
||||
<Import Project="$([MSBuild]::GetPathOfFileAbove(directory.build.props))" Condition="Exists('$([MSBuild]::GetPathOfFileAbove(directory.build.props))')" />
|
||||
<PropertyGroup>
|
||||
<InputFile>$(RepositoryDirectory)Common\Labs.TargetFrameworks.default.props</InputFile>
|
||||
<OutputFile>$(RepositoryDirectory)Common\Labs.TargetFrameworks.props</OutputFile>
|
||||
</PropertyGroup>
|
||||
|
||||
<Target Name="PruneExtraTargetFrameworks" BeforeTargets="ResolvePackageAssets;PreBuildEvent">
|
||||
<WriteLinesToFile Condition="'$(SolutionFileName)' == 'Toolkit.Labs.All.sln' or '$(SolutionFileName)' == ''" Overwrite="true" Encoding="Unicode"
|
||||
File="$(OutputFile)" Lines="$([System.IO.File]::ReadAllText('$(InputFile)'))"/>
|
||||
<PropertyGroup>
|
||||
<PowerShellCommand Condition=" '$(OS)' == 'Windows_NT' ">powershell</PowerShellCommand>
|
||||
<PowerShellCommand Condition=" '$(OS)' == 'Unix' ">pwsh</PowerShellCommand>
|
||||
<ClientGenTriggerScript>$(MSBuildProjectDirectory)\..\..\..\.build\client_gen.ps1</ClientGenTriggerScript>
|
||||
</PropertyGroup>
|
||||
|
||||
<WriteLinesToFile Condition="'$(SolutionFileName)' == 'Toolkit.Labs.Windows.sln'"
|
||||
File="$(OutputFile)" Overwrite="true" Encoding="Unicode"
|
||||
Lines="$([System.Text.RegularExpressions.Regex]::Replace($([System.IO.File]::ReadAllText('$(InputFile)')), '<(LinuxLibTargetFramework|AndroidLibTargetFramework|MacOSLibTargetFramework|iOSLibTargetFramework)>.+?>', ''))" />
|
||||
|
||||
<WriteLinesToFile Condition="'$(SolutionFileName)' == 'Toolkit.Labs.Wasm.sln'"
|
||||
File="$(OutputFile)" Overwrite="true" Encoding="Unicode"
|
||||
Lines="$([System.Text.RegularExpressions.Regex]::Replace($([System.IO.File]::ReadAllText('$(InputFile)')), '<(UwpTargetFramework|WinAppSdkTargetFramework|WpfLibTargetFramework|LinuxLibTargetFramework|AndroidLibTargetFramework|MacOSLibTargetFramework|iOSLibTargetFramework)>.+?>', ''))" />
|
||||
<Exec Command="$(PowerShellCommand) -ExecutionPolicy Unrestricted -NoProfile -File $(RepositoryDirectory)Common/Scripts/UpdateTargetFrameworks.ps1 $(SolutionName) --Verbose"
|
||||
WorkingDirectory="$(RepositoryDirectory)Common/Scripts/" />
|
||||
</Target>
|
||||
</Project>
|
|
@ -0,0 +1,19 @@
|
|||
$slnName = $args[0];
|
||||
|
||||
$fileContents = Get-Content -Path .\..\Labs.TargetFrameworks.default.props
|
||||
$newFileContents = $fileContents;
|
||||
|
||||
if ($slnName -eq "Toolkit.Labs.Windows") {
|
||||
$newFileContents = $fileContents -replace '<(LinuxLibTargetFramework|AndroidLibTargetFramework|MacOSLibTargetFramework|iOSLibTargetFramework)>.+?>', '';
|
||||
}
|
||||
|
||||
if ($slnName -eq "Toolkit.Labs.Wasm") {
|
||||
$newFileContents = $fileContents -replace '<(UwpTargetFramework|WinAppSdkTargetFramework|WpfLibTargetFramework|LinuxLibTargetFramework|AndroidLibTargetFramework|MacOSLibTargetFramework|iOSLibTargetFramework)>.+?>', '';
|
||||
}
|
||||
|
||||
if ($newFileContents -eq $fileContents) {
|
||||
return;
|
||||
}
|
||||
|
||||
Clear-Content -Path .\..\Labs.TargetFrameworks.props;
|
||||
Add-Content -Force -Path .\..\Labs.TargetFrameworks.props -Value $newFileContents;
|
Загрузка…
Ссылка в новой задаче