Skip to content

Commit

Permalink
Make SourceBuild.props work on Windows (#53523)
Browse files Browse the repository at this point in the history
* Make SourceBuild.props work on Windows

Contributes to VMR work: dotnet/source-build#3926

Changes are from dotnet/dotnet#46

* Update build.ps1
  • Loading branch information
ViktorHofer authored Jan 22, 2024
1 parent cc9cff3 commit a278a26
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 18 deletions.
23 changes: 16 additions & 7 deletions eng/SourceBuild.props
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@
<SourceBuildTargetFrameworkFilter>netstandard2.0%3bnetstandard2.1%3bnetcoreapp2.1%3bnetcoreapp3.1%3bnet5.0%3bnet6.0%3bnet7.0%3bnet8.0%3bnet9.0</SourceBuildTargetFrameworkFilter>
</PropertyGroup>

<!-- Only run this target in source-build only mode. -->
<Target Name="PrepareGlobalJsonForSourceBuild"
AfterTargets="PrepareInnerSourceBuildRepoRoot"
BeforeTargets="RunInnerSourceBuildCommand">
BeforeTargets="RunInnerSourceBuildCommand"
Condition="'$(ArcadeBuildFromSource)' == 'true'">
<Exec
Command="./eng/scripts/prepare-sourcebuild-globaljson.sh"
WorkingDirectory="$(InnerSourceBuildRepoRoot)" />
Expand All @@ -28,13 +30,11 @@
<Delete Files="$(InnerSourceBuildRepoRoot).globalconfig" />
</Target>

<!--
Build RepoTasks - this is normally triggered via the build script but the inner ArPow source-build is run via msbuild
-->
<!-- Build RepoTasks - this is normally triggered via the build script but the inner ArPow source-build is run via msbuild.
https://github.com/dotnet/source-build/issues/3807 -->
<Target Name="BuildRepoTasks"
Condition="'$(ArcadeInnerBuildFromSource)' == 'true'"
BeforeTargets="Execute">

<!-- If the alternative runtime location and key are present, pass those through -->
<PropertyGroup>
<_AdditionalRepoTaskBuildArgs />
Expand All @@ -45,7 +45,8 @@
<ItemGroup>
<!-- We need to flow FullAssemblySigningSupported even when building repo tasks because they use full signing -->
<InnerBuildEnv Condition="'$(FullAssemblySigningSupported)' != ''" Include="FullAssemblySigningSupported=$(FullAssemblySigningSupported)" />
<InnerBuildEnv Include="DotNetBuildFromSource=true" />
<InnerBuildEnv Include="DotNetBuildFromSource=$(ArcadeBuildFromSource)" />
<InnerBuildEnv Include="DotNetBuildVertical=$(ArcadeBuildVertical)" />
</ItemGroup>

<!-- Call the build.sh script to build the repo tasks. Set IgnoreStandardErrorWarningFormat
Expand All @@ -56,7 +57,15 @@
Command="./eng/build.sh --only-build-repo-tasks -bl $(_AdditionalRepoTaskBuildArgs)"
IgnoreStandardErrorWarningFormat="true"
WorkingDirectory="$(InnerSourceBuildRepoRoot)"
EnvironmentVariables="@(InnerBuildEnv)" />
EnvironmentVariables="@(InnerBuildEnv)"
Condition="'$(OS)' != 'Windows_NT'" />

<Exec
Command=".\eng\build.cmd -OnlyBuildRepoTasks -bl $(_AdditionalRepoTaskBuildArgs)"
IgnoreStandardErrorWarningFormat="true"
WorkingDirectory="$(InnerSourceBuildRepoRoot)"
EnvironmentVariables="@(InnerBuildEnv)"
Condition="'$(OS)' == 'Windows_NT'" />
</Target>

<Target Name="CustomizeInnerBuildArgs"
Expand Down
28 changes: 17 additions & 11 deletions eng/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ Do not build project-to-project references and only build the specified project.
.PARAMETER NoBuildRepoTasks
Skip building eng/tools/RepoTasks/
.PARAMETER OnlyBuildRepoTasks
Only build eng/tools/RepoTasks/ and nothing else.
.PARAMETER Pack
Produce packages.
Expand Down Expand Up @@ -159,6 +162,7 @@ param(
[switch]$NoBuildInstallers,

[switch]$NoBuildRepoTasks,
[switch]$OnlyBuildRepoTasks,

# Diagnostics
[Alias('bl')]
Expand Down Expand Up @@ -437,20 +441,22 @@ try {
@ToolsetBuildArguments
}

if ($performDesktopBuild) {
Write-Host
Remove-Item variable:global:_BuildTool -ErrorAction Ignore
$msbuildEngine = 'vs'
if (-not $OnlyBuildRepoTasks) {
if ($performDesktopBuild) {
Write-Host
Remove-Item variable:global:_BuildTool -ErrorAction Ignore
$msbuildEngine = 'vs'

MSBuild $toolsetBuildProj /p:RepoRoot=$RepoRoot @MSBuildArguments
}
MSBuild $toolsetBuildProj /p:RepoRoot=$RepoRoot @MSBuildArguments
}

if ($performDotnetBuild) {
Write-Host
Remove-Item variable:global:_BuildTool -ErrorAction Ignore
$msbuildEngine = 'dotnet'
if ($performDotnetBuild) {
Write-Host
Remove-Item variable:global:_BuildTool -ErrorAction Ignore
$msbuildEngine = 'dotnet'

MSBuild $toolsetBuildProj /p:RepoRoot=$RepoRoot @dotnetBuildArguments
MSBuild $toolsetBuildProj /p:RepoRoot=$RepoRoot @dotnetBuildArguments
}
}
}
catch {
Expand Down

0 comments on commit a278a26

Please sign in to comment.