Skip to content

Conversation

@kzu
Copy link
Member

@kzu kzu commented Sep 1, 2025

The SDK mode allows us to support the #:sdk directive such that our SDK imports the generated .sdk.props and .sdk.targets files. It can also set the required ImportProjectExtension* properties for automatically importing the targets during restore (if present in the base intermediate output path).

Even with the added properties, the situation on initial clone/run of a project using SmallSharp was suboptimal:

  • whether in SDK mode or package mode, we'd need a second restore after the initial one and first EmitTargets run. VS does this automatically since it would detect the addition of new extension targets (due to the ImportProjectExtension* props) and restore again as needed. But it wouldn't work from the CLI
  • this meant a dotnet build would fail consistently

So we have a dual mechanism that makes this seamless:

  • In SDK mode we can optimize things by just parsing the startup/active file and injecting the package references before the restore graph is generated
  • In package mode, we re-run restore and temporarily redirect the assets file to a different dynamic one to refresh the resolved assets.

Fixes #143

The SDK mode allows us to support the #:sdk directive such that our SDK imports the generated .sdk.props and .sdk.targets files. It can also set the required `ImportProjectExtension*` properties for automatically importing the targets during restore (if present in the base intermediate output path).

Even with the added properties, the situation on initial clone/run of a project using SmallSharp was suboptimal:
- whether in SDK mode or package mode, we'd need a second restore after the initial one and first EmitTargets run. VS does this automatically since it would detect the addition of new extension targets (due to the ImportProjectExtension* props) and restore again as needed. But it wouldn't work from the CLI
- this meant a dotnet build would fail consistently

So we have a dual mechanism that makes this seamless:
- In SDK mode we can optimize things by just parsing the startup/active file and injecting the package references before the restore graph is generated
- In package mode, we re-run restore and temporarily redirect the assets file to a different dynamic one to refresh the resolved assets.

Fixes #143
@kzu kzu added the enhancement New feature or request label Sep 1, 2025
@kzu kzu enabled auto-merge (rebase) September 1, 2025 21:23
@kzu kzu merged commit 6bec658 into main Sep 1, 2025
9 checks passed
@kzu kzu deleted the dev/sdks branch September 1, 2025 21:24
@devlooped devlooped locked and limited conversation to collaborators Oct 2, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add support for #:sdk directive

2 participants