Skip to content

Commit 1a7d1a0

Browse files
authored
Restore using msbuild (newrelic#371)
* Use MSBuild instead of NuGet to restore solution packages * Restore is not a separate step with msbuild * Fix conditional for self-signed cert
1 parent 51b1c5f commit 1a7d1a0

File tree

3 files changed

+26
-83
lines changed

3 files changed

+26
-83
lines changed

.github/workflows/all_solutions.yml

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -51,22 +51,16 @@ jobs:
5151
Remove-Item -Path "${{ github.workspace }}\src\Agent\_profilerBuild\linux-release" -Recurse -Force -ErrorAction SilentlyContinue
5252
shell: powershell
5353

54-
- name: Install dependencies
55-
run: |
56-
Write-Host ${{ env.tools_path }}\nuget.exe restore ${{ env.profiler_solution_path }} -NoCache -Source `"https://www.nuget.org/api/v2`"
57-
${{ env.tools_path }}\nuget.exe restore ${{ env.profiler_solution_path }} -NoCache -Source "https://www.nuget.org/api/v2"
58-
shell: powershell
59-
6054
- name: Build x64
6155
run: |
62-
Write-Host "MSBuild.exe -m -p:Platform=x64 -p:Configuration=Release ${{ env.profiler_solution_path }}"
63-
MSBuild.exe -m -p:Platform=x64 -p:Configuration=Release ${{ env.profiler_solution_path }}
56+
Write-Host "MSBuild.exe -restore -m -p:Platform=x64 -p:Configuration=Release ${{ env.profiler_solution_path }}"
57+
MSBuild.exe -restore -m -p:Platform=x64 -p:Configuration=Release ${{ env.profiler_solution_path }}
6458
shell: powershell
6559

6660
- name: Build x86
6761
run: |
68-
Write-Host "MSBuild.exe -m -p:Platform=Win32 -p:Configuration=Release ${{ env.profiler_solution_path }}"
69-
MSBuild.exe -m -p:Platform=Win32 -p:Configuration=Release ${{ env.profiler_solution_path }}
62+
Write-Host "MSBuild.exe -restore -m -p:Platform=Win32 -p:Configuration=Release ${{ env.profiler_solution_path }}"
63+
MSBuild.exe -restore -m -p:Platform=Win32 -p:Configuration=Release ${{ env.profiler_solution_path }}
7064
shell: powershell
7165

7266
- name: Archive Artifacts
@@ -155,23 +149,11 @@ jobs:
155149
with:
156150
name: profiler
157151
path: ${{ github.workspace }}/src/Agent/_profilerBuild/
158-
159-
- name: Install dependencies for FullAgent.sln
160-
run: |
161-
Write-Host ${{ env.tools_path }}\nuget.exe restore ${{ env.fullagent_solution_path }} -NoCache -Source `"https://www.nuget.org/api/v2`"
162-
${{ env.tools_path }}\nuget.exe restore ${{ env.fullagent_solution_path }} -NoCache -Source "https://www.nuget.org/api/v2"
163-
shell: powershell
164-
165-
- name: Install dependencies for MsiInstaller.sln
166-
run: |
167-
Write-Host ${{ env.tools_path }}\nuget.exe restore ${{ env.msi_solution_path }} -NoCache -Source `"https://www.nuget.org/api/v2`"
168-
${{ env.tools_path }}\nuget.exe restore ${{ env.msi_solution_path }} -NoCache -Source "https://www.nuget.org/api/v2"
169-
shell: powershell
170-
152+
171153
- name: Build FullAgent.sln
172154
run: |
173-
Write-Host "MSBuild.exe -m -p:Configuration=Release -p:AllowUnsafeBlocks=true ${{ env.fullagent_solution_path }}"
174-
MSBuild.exe -m -p:Configuration=Release -p:AllowUnsafeBlocks=true ${{ env.fullagent_solution_path }}
155+
Write-Host "MSBuild.exe -restore -m -p:Configuration=Release -p:AllowUnsafeBlocks=true ${{ env.fullagent_solution_path }}"
156+
MSBuild.exe -restore -m -p:Configuration=Release -p:AllowUnsafeBlocks=true ${{ env.fullagent_solution_path }}
175157
shell: powershell
176158

177159
- name: Create agent_version.txt
@@ -232,22 +214,22 @@ jobs:
232214
shell: powershell
233215

234216
- name: Create Self-signed code signing cert
235-
if: ${{ github.event.pull_request || github.event.workflow_dispatch }}
217+
if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch'
236218
run: |
237219
Write-Host "New-SelfSignedCertificate -DnsName "Self-signed code signing cert" -Type CodeSigning -CertStoreLocation Cert:\CurrentUser\My -NotAfter (Get-Date).AddYears(100)"
238220
New-SelfSignedCertificate -DnsName "Self-signed code signing cert" -Type CodeSigning -CertStoreLocation Cert:\CurrentUser\My -NotAfter (Get-Date).AddYears(100)
239221
shell: powershell
240222

241223
- name: Build MsiInstaller.sln x86
242224
run: |
243-
Write-Host "MSBuild.exe -m -p:Configuration=Release -p:AllowUnsafeBlocks=true -p:Platform=x86 ${{ env.msi_solution_path }}"
244-
MSBuild.exe -m -p:Configuration=Release -p:AllowUnsafeBlocks=true -p:Platform=x86 ${{ env.msi_solution_path }}
225+
Write-Host "MSBuild.exe -restore -m -p:Configuration=Release -p:AllowUnsafeBlocks=true -p:Platform=x86 ${{ env.msi_solution_path }}"
226+
MSBuild.exe -restore -m -p:Configuration=Release -p:AllowUnsafeBlocks=true -p:Platform=x86 ${{ env.msi_solution_path }}
245227
shell: powershell
246228

247229
- name: Build MsiInstaller.sln x64
248230
run: |
249-
Write-Host "MSBuild.exe -m -p:Configuration=Release -p:AllowUnsafeBlocks=true -p:Platform=x64 ${{ env.msi_solution_path }}"
250-
MSBuild.exe -m -p:Configuration=Release -p:AllowUnsafeBlocks=true -p:Platform=x64 ${{ env.msi_solution_path }}
231+
Write-Host "MSBuild.exe -restore -m -p:Configuration=Release -p:AllowUnsafeBlocks=true -p:Platform=x64 ${{ env.msi_solution_path }}"
232+
MSBuild.exe -restore -m -p:Configuration=Release -p:AllowUnsafeBlocks=true -p:Platform=x64 ${{ env.msi_solution_path }}
251233
shell: powershell
252234

253235
- name: Archive _build Artifacts
@@ -336,16 +318,10 @@ jobs:
336318
- name: Add msbuild to PATH
337319
uses: microsoft/setup-msbuild@v1
338320

339-
- name: Install dependencies for IntegrationTests.sln
340-
run: |
341-
Write-Host ${{ env.tools_path }}\nuget.exe restore ${{ env.integration_solution_path }} -NoCache -Source `"https://www.nuget.org/api/v2`"
342-
${{ env.tools_path }}\nuget.exe restore ${{ env.integration_solution_path }} -NoCache -Source "https://www.nuget.org/api/v2"
343-
shell: powershell
344-
345321
- name: Build IntegrationTests.sln
346322
run: |
347-
Write-Host "MSBuild.exe -m -p:Configuration=Release -p:DeployOnBuild=true -p:PublishProfile=LocalDeploy ${{ env.integration_solution_path }}"
348-
MSBuild.exe -m -p:Configuration=Release -p:DeployOnBuild=true -p:PublishProfile=LocalDeploy ${{ env.integration_solution_path }}
323+
Write-Host "MSBuild.exe -restore -m -p:Configuration=Release -p:DeployOnBuild=true -p:PublishProfile=LocalDeploy ${{ env.integration_solution_path }}"
324+
MSBuild.exe -restore -m -p:Configuration=Release -p:DeployOnBuild=true -p:PublishProfile=LocalDeploy ${{ env.integration_solution_path }}
349325
shell: powershell
350326

351327
- name: Archive Artifacts
@@ -376,16 +352,10 @@ jobs:
376352
- name: Add msbuild to PATH
377353
uses: microsoft/setup-msbuild@v1
378354

379-
- name: Install dependencies for UnboundedIntegrationTests.sln
380-
run: |
381-
Write-Host ${{ env.tools_path }}\nuget.exe restore ${{ env.unbounded_solution_path }} -NoCache -Source `"https://www.nuget.org/api/v2`"
382-
${{ env.tools_path }}\nuget.exe restore ${{ env.unbounded_solution_path }} -NoCache -Source "https://www.nuget.org/api/v2"
383-
shell: powershell
384-
385355
- name: Build UnboundedIntegrationTests.sln
386356
run: |
387-
Write-Host "MSBuild.exe -m -p:Configuration=Release -p:DeployOnBuild=true -p:PublishProfile=LocalDeploy ${{ env.unbounded_solution_path }}"
388-
MSBuild.exe -m -p:Configuration=Release -p:DeployOnBuild=true -p:PublishProfile=LocalDeploy ${{ env.unbounded_solution_path }}
357+
Write-Host "MSBuild.exe -restore -m -p:Configuration=Release -p:DeployOnBuild=true -p:PublishProfile=LocalDeploy ${{ env.unbounded_solution_path }}"
358+
MSBuild.exe -restore -m -p:Configuration=Release -p:DeployOnBuild=true -p:PublishProfile=LocalDeploy ${{ env.unbounded_solution_path }}
389359
shell: powershell
390360

391361
- name: Archive Artifacts
@@ -416,16 +386,10 @@ jobs:
416386
- name: Add msbuild to PATH
417387
uses: microsoft/setup-msbuild@v1
418388

419-
- name: Install dependencies for PlatformTests.sln
420-
run: |
421-
Write-Host ${{ env.tools_path }}\nuget.exe restore ${{ env.platform_solution_path }} -NoCache -Source `"https://www.nuget.org/api/v2`"
422-
${{ env.tools_path }}\nuget.exe restore ${{ env.platform_solution_path }} -NoCache -Source "https://www.nuget.org/api/v2"
423-
shell: powershell
424-
425389
- name: Build PlatformTests.sln
426390
run: |
427-
Write-Host "MSBuild.exe -m -p:Configuration=Release ${{ env.platform_solution_path }}"
428-
MSBuild.exe -m -p:Configuration=Release ${{ env.platform_solution_path }}
391+
Write-Host "MSBuild.exe -restore -m -p:Configuration=Release ${{ env.platform_solution_path }}"
392+
MSBuild.exe -restore -m -p:Configuration=Release ${{ env.platform_solution_path }}
429393
shell: powershell
430394

431395
run-integration-tests:

build/build.ps1

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ $ErrorActionPreference = "Stop"
2424

2525
Write-Host "Performing validation"
2626
$rootDirectory = Resolve-Path "$(Split-Path -Parent $PSCommandPath)\.."
27-
$nugetPath = (Resolve-Path "$rootDirectory\build\Tools\nuget.exe").Path
2827
$vsWhere = (Resolve-Path "$rootDirectory\build\Tools\vswhere.exe").Path
2928
$msBuildPath = & "$vsWhere" -products 'Microsoft.VisualStudio.Product.BuildTools' -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
3029
if (!$msBuildPath) {
@@ -64,19 +63,6 @@ $solutions = [Ordered]@{
6463
"$rootDirectory\tests\Agent\PlatformTests\PlatformTests.sln" = @("Configuration=$Configuration");
6564
}
6665

67-
#################
68-
# NuGet Restore #
69-
#################
70-
71-
Write-Host "Restoring NuGet packages"
72-
foreach ($sln in $solutions.Keys) {
73-
& $nugetPath restore $sln -NoCache -Source "https://www.nuget.org/api/v2"
74-
if ($LastExitCode -ne 0) {
75-
Write-Host "Error during NuGet restore. Exiting with code: $LastExitCode.."
76-
exit $LastExitCode
77-
}
78-
}
79-
8066
#########
8167
# Build #
8268
#########
@@ -88,16 +74,18 @@ $env:SetSessionEnvironment = $SetSessionEnvironment
8874
Write-Host "Building solutions"
8975
foreach ($sln in $solutions.Keys) {
9076
foreach ($config in $solutions.Item($sln)) {
91-
Write-Host "-- Building $sln : '. $msBuildPath -m -p:$($config) $sln'"
92-
. $msBuildPath -nologo -m -p:$($config) $sln
77+
Write-Host "-- Building $sln : '. $msBuildPath -r -m -p:$($config) $sln'"
78+
. $msBuildPath -nologo -r -m -p:$($config) $sln
9379
Write-Host "MSBuild Exit code: $LastExitCode"
9480
if ($LastExitCode -ne 0) {
95-
Write-Host "Error building solution $sln. Exiting with code: $LastExitCode.."
96-
exit $LastExitCode
81+
Write-Host "Error building solution $sln. Exiting with code: $LastExitCode.."
82+
exit $LastExitCode
9783
}
9884
}
9985
}
10086

87+
# temp for debugging
88+
exit 0
10189
$agentVersion = (Get-Item "$rootDirectory\src\_build\AnyCPU-$Configuration\NewRelic.Agent.Core\net45\NewRelic.Agent.Core.dll").VersionInfo.FileVersion
10290

10391
###################

src/Agent/NewRelic/Profiler/build/build.ps1

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ function ExitIfFailLastExitCode {
2020
}
2121

2222
$rootDirectory = Resolve-Path "$(Split-Path -Parent $PSCommandPath)\..\..\..\..\.."
23-
$nugetPath = (Resolve-Path "$rootDirectory\build\Tools\nuget.exe").Path
2423
$vsWhere = (Resolve-Path "$rootDirectory\build\Tools\vswhere.exe").Path
2524
$msBuildPath = & "$vsWhere" -products 'Microsoft.VisualStudio.Product.BuildTools' -latest -requires Microsoft.Component.MSBuild -find MSBuild\**\Bin\MSBuild.exe | select-object -first 1
2625
if (!$msBuildPath) {
@@ -29,13 +28,11 @@ if (!$msBuildPath) {
2928

3029
Write-Host "Building Platform=$Platform and Configuration=$Configuration"
3130

32-
$nugetPath = "$rootDirectory\build\Tools\nuget.exe"
3331
$profilerRoot = "$rootDirectory\src\Agent\NewRelic\Profiler"
3432
$profilerSolutionPath = "$profilerRoot\NewRelic.Profiler.sln"
3533
$outputPath = "$rootDirectory\src\Agent\_profilerBuild"
3634
$linuxOutputPath = "$outputPath\linux-release"
3735

38-
$restoreNuget = $Platform -eq "all" -or $Platform -eq "windows" -or $Platform -eq "x64" -or $Platform -eq "x86"
3936
$buildx64 = $Platform -eq "all" -or $Platform -eq "windows" -or $Platform -eq "x64"
4037
$buildx86 = $Platform -eq "all" -or $Platform -eq "windows" -or $Platform -eq "x86"
4138
$buildLinux = $Platform -eq "all" -or $Platform -eq "linux"
@@ -45,21 +42,15 @@ if ($Platform -eq "all") {
4542
if (Test-Path $outputPath) { Write-Error "Ouput path not cleared out: $outputPath"; exit 1; }
4643
}
4744

48-
if ($restoreNuget) {
49-
Write-Host "-- Profiler build: Restoring NuGet packages"
50-
& $nugetPath restore $profilerSolutionPath -Source "https://www.nuget.org/api/v2"
51-
ExitIfFailLastExitCode
52-
}
53-
5445
if ($buildx64) {
5546
Write-Host "-- Profiler build: x64-$Configuration"
56-
& $msBuildPath /p:Platform=x64 /p:Configuration=$Configuration $profilerSolutionPath
47+
& $msBuildPath /restore /p:Platform=x64 /p:Configuration=$Configuration $profilerSolutionPath
5748
ExitIfFailLastExitCode
5849
}
5950

6051
if ($buildx86) {
6152
Write-Host "-- Profiler build: x86-$Configuration"
62-
& "$msBuildPath" /p:Platform=Win32 /p:Configuration=$Configuration $profilerSolutionPath
53+
& "$msBuildPath" /restore /p:Platform=Win32 /p:Configuration=$Configuration $profilerSolutionPath
6354
ExitIfFailLastExitCode
6455
}
6556

0 commit comments

Comments
 (0)