You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+14-18Lines changed: 14 additions & 18 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,7 +62,7 @@ modify any of the others since they automatically become *None* items.
62
62
63
63
> [!TIP]
64
64
> An initial build after selection change migh be needed to restore the packages and compile the
65
-
> selected file
65
+
> selected file, unless you're using the SDK mode for SmallSharp (see below).
66
66
67
67
All compile files directly under the project directory root are considered top-level programs for
68
68
selection and compilation purposes. If you need to share code among them, you can place additional
@@ -93,10 +93,16 @@ and adding a couple extra properties to the project file:
93
93
</Project>
94
94
```
95
95
96
-
If your file-based apps use the `#:sdk`[directive](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#file-based-apps),
97
-
you need to add SmallSharp as an SDK reference instead so the SDK is picked up by the
98
-
generated targets/props instead of the project file. You also don't need the additional
99
-
properties since the SDK mode sets them automatically for you:
96
+
There are some limitations with this mode, however:
97
+
* You cannot use the `#:sdk`[directive](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/preprocessor-directives#file-based-apps)
98
+
to specify a different SDK per file, since the project file already specifies one.
99
+
* CLI-based builds may require multiple passes to restore and build the selected file, since
100
+
the package is only restored after the first build.
101
+
* You must add ImportProjectExtensionProps/ImportProjectExtensionTargets manually, polluting the
102
+
project file.
103
+
104
+
So the recommended way to use SmallSharp is via the SDK mode, which results in a more streamlined
105
+
and seamless experience across IDE and CLI builds:
100
106
101
107
```xml
102
108
<ProjectSdk="SmallSharp/2.1.0">
@@ -109,6 +115,9 @@ properties since the SDK mode sets them automatically for you:
109
115
</Project>
110
116
```
111
117
118
+
The SDK mode will always produce a successful build in a single `dotnet build` pass even if you
119
+
change the `ActiveFile` between builds.
120
+
112
121
> [!IMPORTANT]
113
122
> If no `#:sdk` directive is provided by a specific C# file-based app, the `Microsoft.NET.SDK` will be
114
123
> used by default in this SDK mode.
@@ -157,19 +166,6 @@ since the "Main" file selection is performed exclusively via MSBuild item manipu
157
166
> SDK reference, and do all project/package references in the top-level files using the `#:package` and
158
167
> `#:property` directives for improved isolation between the different file-based apps.
<ErrorCode="SCS01"Condition="'$(_ImportProjectExtensionProps)' != 'true' or '$(_ImportProjectExtensionTargets)' != 'true'"
40
+
<ErrorCode="SCS02"Condition="'$(_ImportProjectExtensionProps)' != 'true' or '$(_ImportProjectExtensionTargets)' != 'true'"
41
41
Text="Setting ImportProjectExtensionProps and ImportProjectExtensionTargets project properties to 'true' is required by SmallSharp to support C# package and project directives." />
Text="Setting ManagePackageVersionsCentrally to 'true' is not supported by SmallSharp since C# program files can declare package references via #:package directives." />
Text='For maximum compatibility with file-based apps, use SmallSharp as an SDK instead of a package reference: <Project Sdk="SmallSharp/$(SmallSharpVersion)">' />
<ErrorCode="SCS001"Condition="'@(FileBasedSdk)' != '' and '$(UsingSmallSharpSDK)' != 'true'"
180
+
Text="Using #:sdk directives requires using SmallSharp as an SDK instead of a package reference: <Project Sdk='SmallSharp/$(SmallSharpVersion)'>" />
0 commit comments