Skip to content

Commit e189784

Browse files
Allow building the .NET SDK from source with the .NET 8 SDK
1 parent e3d7e7c commit e189784

5 files changed

Lines changed: 24 additions & 4 deletions

File tree

‎sdks/dotnet/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ this command.
4747
## Frameworks supported
4848
- .NET 8.0 or later (the package includes `net8.0` and `net10.0` builds)
4949

50-
Building the SDK from source requires the .NET 10 SDK.
50+
Building the SDK from source works with the .NET 8 SDK (`net8.0` build) or the .NET 10 SDK (`net8.0` and `net10.0` builds).
5151

5252
<a id="dependencies"></a>
5353
## Dependencies

‎sdks/dotnet/src/Dropbox.Sign.Test/Dropbox.Sign.Test.csproj‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
<PropertyGroup>
44
<AssemblyName>Dropbox.Sign.Test</AssemblyName>
55
<RootNamespace>Dropbox.Sign.Test</RootNamespace>
6-
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
6+
<TargetFrameworks>net8.0</TargetFrameworks>
7+
<TargetFrameworks Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '10.0'))">net8.0;net10.0</TargetFrameworks>
78
<IsPackable>false</IsPackable>
89
<PackageId>Dropbox.Sign.Test</PackageId>
910
</PropertyGroup>

‎sdks/dotnet/src/Dropbox.Sign/Dropbox.Sign.csproj‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
<PropertyGroup>
44
<GenerateAssemblyInfo>false</GenerateAssemblyInfo><!-- setting GenerateAssemblyInfo to false causes this bug https://github.com/dotnet/project-system/issues/3934 -->
5-
<TargetFrameworks>net8.0;net10.0</TargetFrameworks>
5+
<!-- net10.0 is built only with the .NET 10 SDK, so the SDK can still be built from source with the .NET 8 SDK -->
6+
<TargetFrameworks>net8.0</TargetFrameworks>
7+
<TargetFrameworks Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '10.0'))">net8.0;net10.0</TargetFrameworks>
68
<AssemblyName>Dropbox.Sign</AssemblyName>
79
<PackageId>Dropbox.Sign</PackageId>
810
<OutputType>Library</OutputType>
@@ -32,4 +34,8 @@
3234
</ItemGroup>
3335
<ItemGroup>
3436
</ItemGroup>
37+
<!-- Published packages must include the net10.0 build -->
38+
<Target Name="RequireNet10ForPack" BeforeTargets="GenerateNuspec" Condition="!$(TargetFrameworks.Contains('net10.0'))">
39+
<Error Text="Packing Dropbox.Sign requires the .NET 10 SDK so the package includes the net10.0 build." />
40+
</Target>
3541
</Project>

‎sdks/dotnet/templates/README.mustache‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ this command.
6565
{{#useCustomTemplateCode}}
6666
- .NET 8.0 or later (the package includes `net8.0` and `net10.0` builds)
6767

68-
Building the SDK from source requires the .NET 10 SDK.
68+
Building the SDK from source works with the .NET 8 SDK (`net8.0` build) or the .NET 10 SDK (`net8.0` and `net10.0` builds).
6969
{{/useCustomTemplateCode}}
7070

7171
<a id="dependencies"></a>

‎sdks/dotnet/templates/netcore_project.mustache‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@
33
<PropertyGroup>{{#useGenericHost}}
44
<GenerateAssemblyInfo>true</GenerateAssemblyInfo> <!-- setting GenerateAssemblyInfo to false causes this bug https://github.com/dotnet/project-system/issues/3934 -->{{/useGenericHost}}{{^useGenericHost}}
55
<GenerateAssemblyInfo>false</GenerateAssemblyInfo><!-- setting GenerateAssemblyInfo to false causes this bug https://github.com/dotnet/project-system/issues/3934 -->{{/useGenericHost}}
6+
{{^useCustomTemplateCode}}
67
<TargetFramework{{#multiTarget}}s{{/multiTarget}}>{{targetFramework}}</TargetFramework{{#multiTarget}}s{{/multiTarget}}>
8+
{{/useCustomTemplateCode}}
9+
{{#useCustomTemplateCode}}
10+
<!-- net10.0 is built only with the .NET 10 SDK, so the SDK can still be built from source with the .NET 8 SDK -->
11+
<TargetFrameworks>net8.0</TargetFrameworks>
12+
<TargetFrameworks Condition="$([MSBuild]::VersionGreaterThanOrEquals('$(NETCoreSdkVersion)', '10.0'))">{{targetFramework}}</TargetFrameworks>
13+
{{/useCustomTemplateCode}}
714
<AssemblyName>{{packageName}}</AssemblyName>
815
<PackageId>{{packageName}}</PackageId>
916
<OutputType>Library</OutputType>
@@ -153,4 +160,10 @@
153160
{{/net48}}
154161
</ItemGroup>
155162
{{/useGenericHost}}
163+
{{#useCustomTemplateCode}}
164+
<!-- Published packages must include the net10.0 build -->
165+
<Target Name="RequireNet10ForPack" BeforeTargets="GenerateNuspec" Condition="!$(TargetFrameworks.Contains('net10.0'))">
166+
<Error Text="Packing {{packageName}} requires the .NET 10 SDK so the package includes the net10.0 build." />
167+
</Target>
168+
{{/useCustomTemplateCode}}
156169
{{>netcore_project.additions}}</Project>

0 commit comments

Comments
 (0)