Skip to content

Commit cbeef22

Browse files
authored
Merge pull request #85 from microting/copilot/fix-84
Fix rebuild.ps1 script failure in GitHub Actions by adding proper restore and build steps
2 parents 180338a + 68c2619 commit cbeef22

File tree

1 file changed

+56
-2
lines changed

1 file changed

+56
-2
lines changed

test/EFCore.MySql.IntegrationTests/scripts/rebuild.ps1

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,60 @@ Push-Location (Join-Path (Split-Path $MyInvocation.MyCommand.Path) "../")
1717

1818
try
1919
{
20-
dotnet tool restore;
20+
Write-Host "Starting rebuild process..."
21+
22+
# First, restore packages with error handling
23+
Write-Host "Restoring packages..."
24+
dotnet restore --ignore-failed-sources --property WarningsAsErrors= --property TreatWarningsAsErrors=false
25+
if ($LASTEXITCODE -ne 0) {
26+
Write-Error "Package restore failed"
27+
exit $LASTEXITCODE
28+
}
29+
30+
# Build the project to ensure it compiles
31+
Write-Host "Building project..."
32+
dotnet build -c Debug --no-restore
33+
if ($LASTEXITCODE -ne 0) {
34+
Write-Error "Build failed"
35+
exit $LASTEXITCODE
36+
}
37+
38+
# Restore dotnet tools
39+
Write-Host "Restoring dotnet tools..."
40+
dotnet tool restore --ignore-failed-sources
41+
if ($LASTEXITCODE -ne 0) {
42+
Write-Warning "Tool restore failed, trying alternative approach..."
43+
44+
# Try installing EF Core tools globally as a fallback
45+
dotnet tool install --global dotnet-ef --ignore-failed-sources
46+
if ($LASTEXITCODE -ne 0) {
47+
Write-Warning "Global EF tool install also failed, but continuing..."
48+
}
49+
}
2150

22-
Remove-Item (Join-Path "Migrations" "*.cs")
51+
# Remove existing migrations
52+
Write-Host "Removing existing migrations..."
53+
if (Test-Path (Join-Path "Migrations" "*.cs")) {
54+
Remove-Item (Join-Path "Migrations" "*.cs")
55+
}
2356

57+
# Drop database
58+
Write-Host "Dropping database..."
2459
dotnet ef database drop -f
60+
if ($LASTEXITCODE -ne 0) {
61+
Write-Warning "Database drop failed, but continuing..."
62+
}
63+
64+
# Add initial migration
65+
Write-Host "Adding Initial migration..."
2566
dotnet ef migrations add Initial
67+
if ($LASTEXITCODE -ne 0) {
68+
Write-Error "Migration add failed"
69+
exit $LASTEXITCODE
70+
}
2671

2772
# add using System.Collections.Generic to the migration files
73+
Write-Host "Updating migration files..."
2874
Get-ChildItem (Join-Path "Migrations" "*.cs") | ForEach-Object {
2975
if (!( select-string -pattern "using System.Collections.Generic;" -path $_.FullName))
3076
{
@@ -33,7 +79,15 @@ try
3379
}
3480
}
3581

82+
# Update database
83+
Write-Host "Updating database..."
3684
dotnet ef database update
85+
if ($LASTEXITCODE -ne 0) {
86+
Write-Error "Database update failed"
87+
exit $LASTEXITCODE
88+
}
89+
90+
Write-Host "Rebuild process completed successfully!"
3791
}
3892
finally
3993
{

0 commit comments

Comments
 (0)