fix: Add script to dynamically change the generated csproj files to t… #21
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Static Code Analysis | |
on: | |
push: | |
branches: | |
- feat/static-analysis | |
workflow_dispatch: | |
jobs: | |
analyze: | |
runs-on: ubuntu-latest | |
steps: | |
# Checkout - Checks out the code | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
lfs: true | |
# Cache Sets up a Caching mechanism to save on repeat runs | |
- uses: actions/cache@v3 | |
with: | |
path: Library | |
key: Library-${{ hashFiles('Assets/**', 'Packages/**', 'ProjectSettings/**') }} | |
restore-keys: | | |
Library- | |
# Setup the .NET Core to make analyzers run properly | |
- name: Set up .NET Core | |
uses: actions/setup-dotnet@v2 | |
with: | |
dotnet-version: '6.0.x' | |
# Build (Specifically targetting StandaloneLinux64) | |
- name: Build project | |
uses: game-ci/unity-builder@v4 | |
env: | |
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }} | |
UNITY_EMAIL: ${{ secrets.UNITY_EMAIL }} | |
UNITY_PASSWORD: ${{ secrets.UNITY_PASSWORD }} | |
with: | |
targetPlatform: StandaloneLinux64 | |
continue-on-error: true | |
# Modifies the project files after they have been generated | |
- name: Modify Project Files to Target .NET Standard | |
run: | | |
find . -name "*.csproj" -exec sed -i 's/<TargetFrameworkVersion>v4.7.1<\/TargetFrameworkVersion>/<TargetFrameworkVersion>v4.7.2<\/TargetFrameworkVersion>/g' {} + | |
# Used to explore the contents of various directories while workflow is | |
# being developed. | |
- name: Investigate | |
run: | | |
ls -al ./ | |
continue-on-error: true | |
# Restores NuGet packages (of which the Roslynator Analyzers are members) | |
- name: Restore NuGet packages | |
run: | | |
# Assuming Unity generates files in the root or known subdirectory | |
dotnet restore workspace.sln # Update with the correct path | |
continue-on-error: true | |
# Actually run the static code analysis of the project | |
- name: Run static code analysis | |
run: | | |
dotnet build workspace.sln /warnaserror /p:TreatWarningsAsErrors=true # Update with the correct path |