Add recipeInstallDir to CSharpRewriteRpc so callers control the recipe project location#7819
Open
shanman190 wants to merge 2 commits into
Open
Add recipeInstallDir to CSharpRewriteRpc so callers control the recipe project location#7819shanman190 wants to merge 2 commits into
shanman190 wants to merge 2 commits into
Conversation
…e project location The recipe project — where `dotnet add package` resolves recipe NuGet packages — was always created under a private temp directory. Because dotnet discovers NuGet.config by walking up from the project directory, a caller had no way to inject a package feed via a generated NuGet.config. Mirror the JavaScript RPC's recipeInstallDir/--recipe-install-dir pattern: the C# server now creates Recipes.csproj in a caller-supplied directory when one is provided (otherwise the previous temp-dir behavior), so a co-located NuGet.config is honored by dotnet's config discovery. - CSharpRewriteRpc.Builder.recipeInstallDir(Path) appends --recipe-install-dir= to the server command (tool-path, csproj, and explicit-entry paths) - Program.cs parses --recipe-install-dir= and threads it through RunAsync - RewriteRpcServer creates the recipe project under that directory when set
Member
|
what was the user visible effect prior to this change? What was broken and fixed with this? We have MS build demos going on next week, so would like to inform the team going there if something has materially changed. |
EnsureRecipesProject unconditionally wrote a nuget.config (nuget.org + local-feed) into the recipe project dir when ~/.nuget/local-feed exists. Now that the project dir can be a caller-supplied recipeInstallDir, that overwrote a caller's config (e.g. an exclusive configured feed). Make the local feed additive instead: BuildRecipesNuGetConfig creates the public + local-feed config only when none exists, and otherwise appends only the local feed to the existing <packageSources> (idempotently, preserving the caller's sources and any <clear/>). Local-dev-only; no-ops in production where local-feed is absent.
Contributor
Author
|
This is needed to help support the CLI when installing recipes from private sources only. We need to be able to apply some changes to the temporary install project that is created for each recipe install, but unlike all of the other RPC implementations, C# was missing this mechanism. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The C# RPC server always creates its recipe project (the
Recipes.csprojagainst whichdotnet add packageresolves recipe NuGet packages) under a private temp directory. Because dotnet discoversNuGet.configby walking up from the project directory, a caller (e.g. the Moderne CLI) had no way to inject a package feed via a generatedNuGet.config— there was nowhere to put it that dotnet would find.Solution
Bring the C# RPC up to parity with the JavaScript, Python, and Go RPC servers, which already expose
recipeInstallDir/--recipe-install-dir. The C# server now createsRecipes.csprojin a caller-supplied directory when one is provided (otherwise the previous temp-dir behavior is unchanged), so aNuGet.configco-located in that directory is honored by dotnet's project-directory config discovery.CSharpRewriteRpc.Builder.recipeInstallDir(Path)appends--recipe-install-dir=to the server command (tool-path, csproj, and explicit-entry paths)Program.csparses--recipe-install-dir=and threads it throughRunAsyncRewriteRpcServercreates the recipe project under that directory when setThe change is additive and backward-compatible: the new constructor/builder/RunAsync parameters default to the prior behavior.
Context
Unblocks the Moderne CLI
mod config recipes nuget installfeature so it can resolve recipes from a configured artifact repository (the CLI writes aNuGet.configinto the install dir). npm/pip/go deliver their configured feed via environment variables and need no server change; nuget is file-based, hence this hook.Testing
:rewrite-csharp:compileJavabuild clean.CsprojParseTestsRPC integration tests requireRPC_TEST_SERVER_CLASSPATH(or./gradlew :rewrite-csharp:rpcTestClasspath) and fail identically onmainin a bare checkout — unrelated to this change.