Split C# NuGet into library and tool packages#6912
Merged
jkschneider merged 1 commit intomainfrom Mar 10, 2026
Merged
Conversation
PackAsTool=true causes NuGet to place DLLs in tools/ instead of lib/, making types unavailable at compile time for downstream PackageReference consumers. The OpenRewrite.csproj was both a library (SDK types like Recipe, CSharpVisitor) and a tool (Program.cs for the RPC server), so the packed .nupkg put everything in tools/ and was unusable as a dependency. Split into two projects: - OpenRewrite.CSharp (library) — all SDK types, packable with DLLs in lib/ via PackageReference - OpenRewrite.CSharp.Tool (tool) — just Program.cs with a ProjectReference to the library, packed with PackAsTool=true for dotnet tool install Also adds a csharpPublishLocal task for local NuGet feed development and simplifies the snapshot version logic to always use timestamps.
6425235 to
2b6dda3
Compare
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.
Summary
OpenRewrite.csprojinto two projects:OpenRewrite.CSharp(library) andOpenRewrite.CSharp.Tool(tool).PackAsTool=truecauses NuGet to place DLLs intools/instead oflib/, making types unavailable at compile time for downstreamPackageReferenceconsumers. Since the project was both a library and a tool, the packed.nupkgwas unusable as a dependency.OpenRewrite.CSharp(library) contains all SDK types (Recipe, CSharpVisitor, etc.), packable with DLLs inlib/— this is what downstream projects reference viaPackageReference.OpenRewrite.CSharp.Tool(tool) contains justProgram.cswith aProjectReferenceto the library, packed withPackAsTool=truefordotnet tool install rewrite-csharp.csharpPublishLocalGradle task for local NuGet feed development (~/.nuget/local-feed/).-devsuffix for non-CI builds).Test plan
./gradlew :rewrite-csharp:csharpPackproduces both.nupkgfiles indist/dotnet tool installworks with theOpenRewrite.CSharp.ToolpackagePackageReferencetoOpenRewrite.CSharpresolves SDK types at compile time./gradlew :rewrite-csharp:csharpPublishLocalpublishes to~/.nuget/local-feed/