Skip to content

fix: generate .csproj projects instead of #r scripts#42

Merged
JusterZhu merged 1 commit into
mainfrom
fix/csproj-generation
May 20, 2026
Merged

fix: generate .csproj projects instead of #r scripts#42
JusterZhu merged 1 commit into
mainfrom
fix/csproj-generation

Conversation

@JusterZhu
Copy link
Copy Markdown
Collaborator

Replace #r NuGet scripts with proper .csproj projects:

  • Generate client/client.csproj + client/Program.cs
  • Generate upgrade/upgrade.csproj + upgrade/Program.cs
  • Run via dotnet run --project . from each directory
  • Uses Microsoft.NET.Sdk with PackageReference (same as normal projects)
  • No #r directives, no CS7011 errors, no NuGet version glob issues

Build: 0 errors

- Replace single-file .cs with client/Program.cs + client/client.csproj
- Replace single-file .cs with upgrade/Program.cs + upgrade/upgrade.csproj
- Use dotnet run --project . instead of dotnet run script.cs
- #r directives are not supported in .cs files by .NET 10
- .csproj approach is more reliable, no NuGet version issues
Copilot AI review requested due to automatic review settings May 20, 2026 16:13
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR updates the simulation workflow to generate and run full console projects (.csproj + Program.cs) for the client and upgrade steps, replacing the previous #r-based C# script approach.

Changes:

  • Generate client/client.csproj + Program.cs and upgrade/upgrade.csproj + Program.cs instead of client.cs / upgrade.cs scripts.
  • Update simulation execution to run the generated projects via dotnet run --project . from each generated directory.
  • Update logging/messages to reflect the project-based generation/execution flow.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/Services/SimulationService.cs Switches simulation runtime from script execution to running generated project directories via dotnet run.
src/Services/ClientGeneratorService.cs Replaces script templates with .csproj + Program.cs templates and writes them into client/ and upgrade/ subfolders.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +139 to 149
await File.WriteAllTextAsync(Path.Combine(clientDir, "Program.cs"),
string.Format(ClientProgram,
EscapeForCSharp(config.AppDirectory),
serverUrl,
"upgrade.exe", // AppName
"client.exe", // MainAppName
config.CurrentVersion,
"1.0.0.0", // upgrade client version
config.ProductId,
config.AppSecretKey),
Encoding.UTF8);
Comment on lines +156 to +157
string.Format(UpgradeProgram,
EscapeForCSharp(config.AppDirectory)),
Comment on lines +23 to +27
<ItemGroup>
<PackageReference Include="GeneralUpdate.ClientCore" Version="10.*" />
<PackageReference Include="GeneralUpdate.Core" Version="10.*" />
</ItemGroup>
</Project>
Comment on lines +91 to +92
<PackageReference Include="GeneralUpdate.Core" Version="10.*" />
<PackageReference Include="GeneralUpdate.ClientCore" Version="10.*" />
@@ -57,14 +57,14 @@ public async Task<SimulationResult> RunAsync(
config.ServerPort = _server.Port;

// 4. Generate client/upgrade scripts
Log("STEP 5: Running client (dotnet run client.cs)", progress);
var clientResult = await RunDotNetScript(config.OutputDirectory, "client.cs", ct);
// 5. Run client via dotnet run --project
Log("STEP 5: Running client (dotnet run --project client)", progress);
@JusterZhu JusterZhu merged commit 90bfc0e into main May 20, 2026
1 check passed
@JusterZhu JusterZhu deleted the fix/csproj-generation branch May 20, 2026 17:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants