Skip to content

Commit

Permalink
(build) Only build projects required by Chocolatey
Browse files Browse the repository at this point in the history
Due to the builds starting to fail both internally and on GitHub
Actions, we need to make some changes to the way the build is done.
The suspicion is that due to a new version of Visual Studio, or perhaps
the SDK, the part of the build the deals with the building of the
Visual Studio Extension is failing.  Since we don't actually need this
project to be built for what Chocolatey needs, let reduce the amount of
projects that are built, being very specific about which projects are
compiled.

This has been achieved by adding a new -ChocolateyBuild parameter,
which is passed into MSBuild as a parameter, and which then chooses
only the projects that we want/need.  This has been tested locally, and
proven to complete, so time to try it out on CI...
  • Loading branch information
gep13 committed Apr 21, 2023
1 parent aaae2b9 commit 6a10678
Show file tree
Hide file tree
Showing 5 changed files with 144 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ jobs:
- name: Configure .Net and other dependencies
run: .\configure.ps1
- name: Build
run: .\build.ps1 -CI -SkipUnitTest
run: .\build.ps1 -CI -SkipUnitTest -ChocolateyBuild
2 changes: 1 addition & 1 deletion .teamcity/settings.kts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ object ChocolateyNugetClient : BuildType({
name = "Build"
scriptMode = script {
content = """
.\build.ps1 -CI -SkipUnitTest -BuildNumber %build.counter% -ReleaseLabel beta -BuildDate (Get-Date -Format "yyyyMMdd")
.\build.ps1 -CI -SkipUnitTest -ChocolateyBuild -BuildNumber %build.counter% -ReleaseLabel beta -BuildDate (Get-Date -Format "yyyyMMdd")
""".trimIndent()
}
}
Expand Down
38 changes: 33 additions & 5 deletions build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ param (
[switch]$PackageEndToEnd,
[switch]$SkipDelaySigning,
[switch]$Binlog,
[switch]$IncludeApex
[switch]$IncludeApex,
##################################
# Chocolatey Specific Modification
##################################
[switch]$ChocolateyBuild
)

. "$PSScriptRoot\build\common.ps1"
Expand Down Expand Up @@ -111,7 +115,13 @@ Invoke-BuildStep 'Running Restore' {
Trace-Log ". `"$MSBuildExe`" $restoreArgs"
& $MSBuildExe @restoreArgs

$restoreArgs = "build\build.proj", "/t:RestoreVS", "/p:Configuration=$Configuration", "/p:ReleaseLabel=$ReleaseLabel", "/p:IncludeApex=$IncludeApex", "/v:m", "/m"
########################################
# Start Chocolatey Specific Modification
########################################
$restoreArgs = "build\build.proj", "/t:RestoreVS", "/p:Configuration=$Configuration", "/p:ReleaseLabel=$ReleaseLabel", "/p:IncludeApex=$IncludeApex", "/p:ChocolateyBuild=$ChocolateyBuild", "/v:m", "/m"
########################################
# End Chocolatey Specific Modification
########################################

if ($BuildNumber)
{
Expand Down Expand Up @@ -142,7 +152,13 @@ Invoke-BuildStep 'Running Restore' {

Invoke-BuildStep $VSMessage {

$buildArgs = 'build\build.proj', "/t:$VSTarget", "/p:Configuration=$Configuration", "/p:ReleaseLabel=$ReleaseLabel", "/p:IncludeApex=$IncludeApex", '/v:m', '/m'
########################################
# Start Chocolatey Specific Modification
########################################
$buildArgs = 'build\build.proj', "/t:$VSTarget", "/p:Configuration=$Configuration", "/p:ReleaseLabel=$ReleaseLabel", "/p:IncludeApex=$IncludeApex", "/p:ChocolateyBuild=$ChocolateyBuild", '/v:m', '/m'
########################################
# End Chocolatey Specific Modification
########################################

if ($BuildNumber)
{
Expand Down Expand Up @@ -191,7 +207,13 @@ Invoke-BuildStep 'Creating the EndToEnd test package' {
Invoke-BuildStep 'Running Restore RTM' {

# Restore for VS
$restoreArgs = "build\build.proj", "/t:RestoreVS", "/p:Configuration=$Configuration", "/p:BuildRTM=true", "/p:ReleaseLabel=$ReleaseLabel", "/p:ExcludeTestProjects=true", "/v:m", "/m"
########################################
# Start Chocolatey Specific Modification
########################################
$restoreArgs = "build\build.proj", "/t:RestoreVS", "/p:Configuration=$Configuration", "/p:BuildRTM=true", "/p:ReleaseLabel=$ReleaseLabel", "/p:ExcludeTestProjects=true", "/p:ChocolateyBuild=$ChocolateyBuild", "/v:m", "/m"
########################################
# End Chocolatey Specific Modification
########################################

if ($BuildNumber)
{
Expand Down Expand Up @@ -224,7 +246,13 @@ Invoke-BuildStep 'Running Restore RTM' {
Invoke-BuildStep 'Packing RTM' {

# Build and (If not $SkipUnitTest) Pack, Core unit tests, and Unit tests for VS
$packArgs = "build\build.proj", "/t:BuildVS`;Pack", "/p:Configuration=$Configuration", "/p:BuildRTM=true", "/p:ReleaseLabel=$ReleaseLabel", "/p:ExcludeTestProjects=true", "/v:m", "/m"
########################################
# Start Chocolatey Specific Modification
########################################
$packArgs = "build\build.proj", "/t:BuildVS`;Pack", "/p:Configuration=$Configuration", "/p:BuildRTM=true", "/p:ReleaseLabel=$ReleaseLabel", "/p:ExcludeTestProjects=true", "/p:ChocolateyBuild=$ChocolateyBuild", "/v:m", "/m"
########################################
# End Chocolatey Specific Modification
########################################

if ($BuildNumber)
{
Expand Down
40 changes: 39 additions & 1 deletion build/build.proj
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,31 @@
Properties="$(CommonMSBuildProperties)" />
</Target>

<!--
============================================================
Start Chocolatey Specific Modification
============================================================
-->

<!--
============================================================
Build Chocolatey Components
============================================================
-->
<Target Name="BuildChocolatey" AfterTargets="BuildVS" Condition=" '$(ChocolateyBuild)' == 'true' ">
<Message Text="Building Chocolatey Components" Importance="high" />

<MSBuild Projects="@(SolutionProjects)"
Targets="Build"
Properties="$(CommonMSBuildProperties)" />
</Target>

<!--
============================================================
End Chocolatey Specific Modification
============================================================
-->

<!--
============================================================
Build XPLAT
Expand All @@ -185,7 +210,20 @@
BuildVS runs the NoVSIX targets before this one.
============================================================
-->
<Target Name="BuildVSIX" AfterTargets= "BuildVS" Condition=" '$(IsXPlat)' != 'true' AND '$(BuildRTM)' != 'true'">

<!--
============================================================
Start Chocolatey Specific Modification
============================================================
-->

<Target Name="BuildVSIX" AfterTargets= "BuildVS" Condition=" '$(IsXPlat)' != 'true' AND '$(BuildRTM)' != 'true' AND '$(ChocolateyBuild)' != 'true' ">

<!--
============================================================
End Chocolatey Specific Modification
============================================================
-->
<Message Text="Building the VSIX" Importance="high" />

<MSBuild Projects="$(VSIXProject)"
Expand Down
72 changes: 70 additions & 2 deletions build/common.project.props
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,17 @@
</ItemGroup>

<!-- All projects in the repository -->
<ItemGroup Condition=" '$(IsXPlat)' != 'true' ">
<!--
============================================================
Start Chocolatey Specific Modification
============================================================
-->
<ItemGroup Condition=" '$(IsXPlat)' != 'true' AND '$(ChocolateyBuild)' != 'true' ">
<!--
============================================================
End Chocolatey Specific Modification
============================================================
-->
<SolutionProjects Include="$(RepositoryRootDirectory)test\*\*\*.csproj"
Exclude="$(RepositoryRootDirectory)test\EndToEnd\*\*.csproj;
$(RepositoryRootDirectory)test\NuGet.Tests.Apex\*\*.csproj"
Expand All @@ -264,8 +274,66 @@
Exclude="$(VSIXProject)" />
</ItemGroup>

<!--
============================================================
Start Chocolatey Specific Modification
============================================================
-->

<!-- Include only project for Chocolatey -->
<ItemGroup Condition=" '$(ChocolateyBuild)' == 'true' ">
<SolutionProjects Include="$(RepositoryRootDirectory)src\NuGet.Core\NuGet.Frameworks\NuGet.Frameworks.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.Commands\NuGet.Commands.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.Protocol\NuGet.Protocol.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.Packaging\NuGet.Packaging.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.Common\NuGet.Common.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.Configuration\NuGet.Configuration.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.PackageManagement\NuGet.PackageManagement.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.DependencyResolver.Core\NuGet.DependencyResolver.Core.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.ProjectModel\NuGet.ProjectModel.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.Resolver\NuGet.Resolver.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.Versioning\NuGet.Versioning.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.Credentials\NuGet.Credentials.csproj;
$(RepositoryRootDirectory)src\NuGet.Core\NuGet.LibraryModel\\NuGet.LibraryModel.csproj;"/>

<CoreUnitTestProjects Include="$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.Commands.Test\NuGet.Commands.Test.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.Common.Test\NuGet.Common.Test.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.Configuration.Test\NuGet.Configuration.Test.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.Credentials.Test\NuGet.Credentials.Test.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.DependencyResolver.Core.Tests\NuGet.DependencyResolver.Core.Tests.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.Frameworks.Test\NuGet.Frameworks.Test.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.LibraryModel.Tests\NuGet.LibraryModel.Tests.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.PackageManagement.Test\NuGet.PackageManagement.Test.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.Packaging.Test\NuGet.Packaging.Test.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.ProjectModel.Test\NuGet.ProjectModel.Test.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.Protocol.Tests\NuGet.Protocol.Tests.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.Resolver.Test\NuGet.Resolver.Test.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.Shared.Tests\NuGet.Shared.Tests.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.Tests\NuGet.Versioning.Test\NuGet.Versioning.Test.csproj" />

<CoreFuncTestProjects Include="$(RepositoryRootDirectory)test\NuGet.Core.FuncTests\NuGet.Commands.FuncTest\NuGet.Commands.FuncTest.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.FuncTests\NuGet.Packaging.FuncTest\NuGet.Packaging.FuncTest.csproj;
$(RepositoryRootDirectory)test\NuGet.Core.FuncTests\NuGet.Protocol.FuncTest\NuGet.Protocol.FuncTest.csproj" />
</ItemGroup>

<!--
============================================================
End Chocolatey Specific Modification
============================================================
-->

<!-- All projects in the repository that support cross platform builds -->
<ItemGroup Condition=" '$(IsXPlat)' == 'true' ">
<!--
============================================================
Start Chocolatey Specific Modification
============================================================
-->
<ItemGroup Condition=" '$(IsXPlat)' == 'true' AND '$(ChocolateyBuild)' != 'true' ">
<!--
============================================================
End Chocolatey Specific Modification
============================================================
-->
<SolutionProjects Include="@(CoreUnitTestProjects)" />
<SolutionProjects Include="@(CoreFuncTestProjects)" />
</ItemGroup>
Expand Down

0 comments on commit 6a10678

Please sign in to comment.