Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDK: Implement Cesium MSBuild Project SDK #561

Merged
merged 45 commits into from
Apr 21, 2024
Merged

Conversation

seclerp
Copy link
Contributor

@seclerp seclerp commented Apr 18, 2024

Summary

Fixes #80

This PR adds basic MSBuild functionality that allows to use of the Cesium compiler via the MSBuild project facade.

What is done:

  1. <Compile> items support
  2. <TargetFramework> property support (only for compiler-supported TFMs)
  3. <OutputType> property support
  4. Tweakable compiler bundle NuGet package installation
  5. .NET Runtime assembly autodetection from SDK (for both netfx and netcore)
  6. Basic validation for property values presence and correctness

More details in docs/msbuild-sdk.md.

Compiler bundles

SDK needs to somehow distribute/obtain the compiler to call it when all necessary command line arguments are collected. This implementation creates bundles as special kinds of NuGet packages with self-contained platform-specific compiler binaries packed into the tools/ folder. That package is then referenced by the SDK.

Global artifacts folder

To drastically simplify custom pack & publish targets I've switched the solution to use the global artifacts/ folder. Also adapted tests after that.

Cesium.Solution.Metadata

In some tests, we need to obtain proper context about the Cesium solution. For that reason there is a special build-only project Cesium.Solution.Metadata that stores some MSBuild properties inside the assembly attribute, wrapped by a helper SolutionMetadata static class. It can be used for any test project that references Cesium.TestFramework.

Tests

SDK tests detailed description was added to docs/tests.md.

Also, edited a bit of test documentation to reflect the use of NUKE instead of dotnet test.

NUKE

SDK pack & publish introduces a new level of complexity for Cesium design-time infrastructure. So I decided to implement it in NUKE instead of plain MSBuild tasks. For existing stuff almost nothing was changed, except for CI and tests - the dotnet test will fail without preparing a compiler bundle in the artifacts folder so it can only be used for specific test projects. Or via prepared NUKE targets.

CodeGen

Some type references didn't work with ref assemblies coming with .NET SDK using GetType, so instead I'm using TypeReference with CorLib TypeSystem, which is compatible with .NET SDK assemblies.

TODO

This PR is almost ready, things to be done:

  • Reuse helpers from Cesium.TestFramework in Cesium.Sdk.Tests

Roadmap

So there is a bunch of stuff that I'm planning to do next in upcoming PRs:

  • Introduce more tests, right now there are only positive smoke tests
  • References (package, project, assemblies) support. This is almost done but needs some more investigation.
  • Project templates

Acknowledgments

Big thanks to @ForNeVeR for Pascal.ABC MSBuild SDK and @kant2002 for F* MSBuild SDK for great examples and motivation!

TODO [~F]

seclerp and others added 30 commits April 18, 2024 14:23
Introduced a "DryRun" boolean to the CesiumCompile class. This option, when set to true, prevents the compiler process from actually starting. This can be used for testing purposes or to verify command line arguments without performing a full compilation.
- Skip ref asm copying
- Generate .runtimeconfig.json
- Fix missing .dll extension
- Fix OutputType in test data
Including netfx tests
seclerp added 2 commits April 18, 2024 14:23
- Add docs about MSBuild SDK
- Add info about SDK tests
- Use NUKE in tests docs
- Rename compiler pack -> compiler bundle
- Introduce CI-friendly single pack and publish compiler bundle targets
@ForNeVeR ForNeVeR self-requested a review April 18, 2024 13:36
@seclerp seclerp marked this pull request as ready for review April 19, 2024 20:33
Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

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

Thanks! I have some comments and small questions, but this is great work and I approve it.

Cesium.Compiler/Cesium.Compiler.csproj Outdated Show resolved Hide resolved
Cesium.Sdk.Tests/SdkTestBase.cs Outdated Show resolved Hide resolved
Cesium.Sdk/Cesium.Sdk.csproj Outdated Show resolved Hide resolved
Cesium.Sdk/Cesium.Sdk.csproj Outdated Show resolved Hide resolved
build/Build.cs Outdated Show resolved Hide resolved
docs/msbuild-sdk.md Outdated Show resolved Hide resolved
docs/msbuild-sdk.md Outdated Show resolved Hide resolved
docs/msbuild-sdk.md Outdated Show resolved Hide resolved
@seclerp seclerp requested a review from ForNeVeR April 21, 2024 13:06
Copy link
Owner

@ForNeVeR ForNeVeR left a comment

Choose a reason for hiding this comment

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

Thanks!

@ForNeVeR ForNeVeR merged commit f6ab861 into ForNeVeR:main Apr 21, 2024
3 checks passed
@seclerp seclerp deleted the msbuild-sdk branch April 28, 2024 16:29
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.

.NET SDK
2 participants