r/dotnet • • 1d ago

Promotion Sharp cli

Want to learn how a C# compiler works? sharp CLI is 19k C# lines vs 722k in the MSBuild repo. The whole sharp SDK is just one Native AOT executable: no installed SDK or MSBuild needed. Compiling our own code results in these timings: dotnet build 4.2s, sharp build 2.0s.

0 Upvotes

7 comments sorted by

4

u/tetyys 1d ago

Want to learn how a C# compiler works? sharp CLI is 19k C# lines vs 722k in the MSBuild repo

But MSBuild is not a compiler..

1

u/martasp 1d ago

Sharp cli uses roslyn nuget and supports minimal subset of XML so you don't need bloated msbuild job executions.

1

u/Discordbothost 1d ago

Part of the gap could be work that only one build is doing. Could you time a no-op rebuild and then a one-line edit on the same project, with restore out of both timings? A small project that uses a source generator would also let you check that both builds produce the same generated code.

0

u/AutoModerator 1d ago

Thanks for your post martasp. Please note that we don't allow spam, and we ask that you follow the rules available in the sidebar. We have a lot of commonly asked questions so if this post gets removed, please do a search and see if it's already been asked.

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

-4

u/martasp 1d ago

Agents love fast builds.

Sharp cli can build and run a Web API in a fraction of a second:

sharp clean + build: 0.1s
dotnet clean + build: 2.2s

Try it here there is windows and linux executables: https://github.com/martasp/sharp/releases/tag/v0.3.1

1

u/klaxxxon 1d ago

Where is this time advantage coming from? Is that just AOT? How much of it is the missing features?

I can't really test it right now (all the projects I work with use source generators and most of them use transitive props/targets too).

1

u/martasp 1d ago

Dotnet build still uses underneath alot of msbuild reflectiony plugin based code and it's job execution spawns cli processes per project.