Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix MSBuild dependency graph resolution #8

Merged
merged 25 commits into from
Dec 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
899fbab
[third_party/RemoteNET] Cleanup project dependency graph
Qonfused Dec 1, 2023
bd57cf8
Add Ref.sln pre-build step
Qonfused Dec 1, 2023
00791d3
Add Build workflow
Qonfused Dec 2, 2023
3a23904
Update workflow trigger
Qonfused Dec 2, 2023
c96c0ea
[MTGOSDK.MSBuild] Create separate MTGO installation task
Qonfused Dec 2, 2023
6f67500
Use default arguments for MSBuild calls
Qonfused Dec 2, 2023
d40aa2d
Use dos newline character for multi-line CLI args
Qonfused Dec 2, 2023
7a91fae
Update build.yml
Qonfused Dec 2, 2023
bf62e47
Update build.yml
Qonfused Dec 2, 2023
2062e4c
Update build.yml
Qonfused Dec 2, 2023
d1ee4b0
Update build.yml
Qonfused Dec 2, 2023
abadb0a
Use default arguments for MSBuild calls
Qonfused Dec 2, 2023
b1af8e1
Test actions caching
Qonfused Dec 2, 2023
c32694d
Merge branch 'msbuild-fix' of https://github.com/videre-project/mtgo-…
Qonfused Dec 2, 2023
6f9a8f6
Update build.yml
Qonfused Dec 2, 2023
7edc816
Use lockfile for restoring NuGet packages
Qonfused Dec 2, 2023
7f6202b
Update cache keys
Qonfused Dec 2, 2023
44ef1cd
Cleanup MSBuild workflow
Qonfused Dec 2, 2023
18cb0fe
Cache NuGet package directories
Qonfused Dec 2, 2023
25ed0ec
Test branch-specific cache updates
Qonfused Dec 2, 2023
0fede1d
Update Build path filters
Qonfused Dec 2, 2023
5141454
Ensure caching is deterministic
Qonfused Dec 2, 2023
317c1b9
Add MTGOSDK.Win32 to solution as main lib dependency
Qonfused Dec 2, 2023
9cf169f
[third_party/RemoteNET] Always run cleanup step
Qonfused Dec 2, 2023
b02633f
README: Add badges with Cloudflare caching
Qonfused Dec 2, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Build
on:
push:
branches: [main]
pull_request:
types: [opened, synchronize, closed, reopened]
paths:
- '**/*.cs'
- '**/*.sln'
- '**/*.proj'
- '**/*.csproj'
- '**/*.vcxproj'
- '**/*.props'
- '**/*.targets'
- '**/packages.lock.json'
workflow_dispatch:
env:
MSBUILD_CACHES: |
**/bin
**/obj
**/Win32
**/x64
MSBUILD_DEFAULTS: /m:2 /v:m /clp:Summary /p:Configuration=Release /p:Platform="Any CPU"
NUGET_CACHES: |
~/.nuget/packages
NUGET_DEFAULTS: -Verbosity quiet -NonInteractive -ConfigFile NuGet.Config -UseLockFile
jobs:
# Runs test suite
build:
runs-on: windows-latest
name: "MSBuild Runner"
steps:
# Fetches remote repository without --progress option.
#
# The default behavior of @actions/checkout outputs many noisy lines of
# status output in the workflow log, which is problematic for log size.
- name: Checkout latest repository commit
uses: actions/checkout@v4
with:
show-progress: false

# Setup the .NET environment
- name: Install .NET Core
uses: actions/setup-dotnet@v3
# Setup MSBuild environment
- name: Setup MSBuild.exe
uses: microsoft/setup-msbuild@v1.3.1
- name: Restore Build Cache
id: msbuild-cache
uses: actions/cache@v3
with:
path: ${{ env.MSBUILD_CACHES }}
key: ${{ runner.os }}-msbuild-${{ github.ref_name }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-msbuild-${{ github.ref_name }}
${{ runner.os }}-msbuild-

# Setup NuGet environment
- name: Setup NuGet
uses: NuGet/setup-nuget@v1.2.0
- name: Restore NuGet Cache
id: nuget-cache
uses: actions/cache@v3
with:
path: ${{ env.NUGET_CACHES }}
key: ${{ runner.os }}-nuget-${{ hashFiles('**/packages.lock.json') }}
restore-keys: |
${{ runner.os }}-nuget-
- name: Restore NuGet packages
if: steps.nuget-cache.outputs.cache-hit != 'true'
run: nuget restore SDK.sln ${{ env.NUGET_DEFAULTS }}

# Build MTGO reference assemblies
- name: Build Reference Assemblies
run: msbuild Ref.sln /t:Build ${{ env.MSBUILD_DEFAULTS }}
# Build the SDK
- name: Build SDK Solution
run: msbuild SDK.sln /t:Build ${{ env.MSBUILD_DEFAULTS }}
27 changes: 21 additions & 6 deletions MTGOSDK.MSBuild/build/MTGOSDK.MSBuild.targets
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
at the end of the build. If it's omitted, that can cause build failures
in subsequent builds because the task assembly can't be overwritten.
-->
<UsingTask AssemblyFile="$(_MTGOSDK_MSBuild)"
TaskName="ExtractMTGOInstallation"
TaskFactory="TaskHostFactory" />
<UsingTask AssemblyFile="$(_MTGOSDK_MSBuild)"
TaskName="GenerateReferenceAssemblies"
TaskFactory="TaskHostFactory" />
Expand All @@ -22,6 +25,23 @@
<Target Name="GenerateReferenceAssemblies"
BeforeTargets="CoreCompile"
DependsOnTargets="ResolveProjectReferences;ResolveAssemblyReferences">
<!--
Extract the MTGO installation directory paths, or create a temporary
extraction directory if no existing MTGO installation could be found.
-->
<ExtractMTGOInstallation
MTGOAppDir="$(MTGOAppDir)"
MTGODataDir="$(MTGODataDir)">
<!-- Expand the glob to the (local) MTGO install/user directories -->
<Output TaskParameter="MTGOAppDir" PropertyName="MTGOAppDir" />
<Output TaskParameter="MTGODataDir" PropertyName="MTGODataDir" />
<!-- Output the MTGO version for use in the consuming project -->
<Output TaskParameter="Version" PropertyName="MTGOVersion" />
</ExtractMTGOInstallation>

<Message Text="MTGOSDK.MSBuild: Extracted MTGO version $(MTGOVersion)"
Importance="high" />

<!--
We build reference assemblies from the latest MTGO installation directory
to ensure that we're only targeting the latest APIs of the MTGO client.
Expand All @@ -31,20 +51,15 @@
-->
<GenerateReferenceAssemblies
MTGOAppDir="$(MTGOAppDir)"
MTGODataDir="$(MTGODataDir)"
Version="$(MTGOVersion)"
OutputPath="$(_MTGOSDK_Refs)">
<!-- Expand the glob to the (local) MTGO install/user directories -->
<Output TaskParameter="MTGOAppDir" PropertyName="MTGOAppDir" />
<Output TaskParameter="MTGODataDir" PropertyName="MTGODataDir" />
<!--
Updates the internal reference path to reflect the new subpath.

Note that this is only resolved after project dependencies are resolved,
and cannot be used as part of any `Reference` item groups.
-->
<Output TaskParameter="OutputPath" PropertyName="_MTGOSDK_Refs" />
<!-- Output the MTGO version for use in the consuming project -->
<Output TaskParameter="Version" PropertyName="MTGOVersion" />
</GenerateReferenceAssemblies>

<!-- TODO: Verify the output reference assemblies w/ ILVerify -->
Expand Down
Loading
Loading