Skip to content

Commit 461446b

Browse files
authored
fix(dotnet): target netcoreapp3.1 with RollForward (#3987)
Issues where encountered with SDK compatibility when the target was set to `net6.0` even when the .NET SDK 6.0 or newer was in use. I suspect this is because of conflicting framework dependency requirements across various packages. Re-target `netcoreapp3.1` while setting a roll-forward policy allowing use of newer major-releases of the SDK when no exact match is found (this is tested to work correctly for all supported .NET SDK releases by our automated test suite).
1 parent 4cbe699 commit 461446b

File tree

8 files changed

+27
-14
lines changed

8 files changed

+27
-14
lines changed

packages/@jsii/dotnet-runtime-test/test/Amazon.JSII.Runtime.IntegrationTests/ComplianceTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -937,7 +937,7 @@ public void OptionalAndVariadicArgumentsTest()
937937
[Fact(DisplayName = Prefix + nameof(JsiiAgentIsCorrect))]
938938
public void JsiiAgentIsCorrect()
939939
{
940-
Assert.Equal("DotNet/" + Environment.Version + "/.NETCoreApp,Version=v6.0/1.0.0.0", JsiiAgent.Value);
940+
Assert.Equal("DotNet/" + Environment.Version + "/.NETCoreApp,Version=v3.1/1.0.0.0", JsiiAgent.Value);
941941
}
942942

943943
[Fact(DisplayName = Prefix + nameof(ReceiveInstanceOfPrivateClass))]

packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime/Amazon.JSII.Runtime.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
<Import Project="../NuGet.Metadata.props" />
33

44
<PropertyGroup>
5-
<TargetFramework>net6.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
6+
<RollForward>Major</RollForward>
67
<PackageId>Amazon.JSII.Runtime</PackageId>
78
<Title>.NET Runtime for JSII</Title>
89
<PackageIcon>icon.png</PackageIcon>

packages/@jsii/dotnet-runtime/src/Amazon.JSII.Runtime/Services/TypeCache.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ void CacheTypes(Assembly assembly)
202202
}
203203
}
204204

205-
return e.Types;
205+
return e.Types ?? Array.Empty<Type?>();
206206
}
207207
}
208208
}

packages/jsii-pacmak/lib/targets/dotnet.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import { toReleaseVersion } from './version-utils';
1818

1919
import { TargetName } from '.';
2020

21-
export const TARGET_FRAMEWORK = 'net6.0';
21+
export const TARGET_FRAMEWORK = 'netcoreapp3.1';
2222

2323
/**
2424
* Build .NET packages all together, by generating an aggregate solution file

packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ export class FileGenerator {
112112
propertyGroup.ele('Nullable', 'enable');
113113
propertyGroup.ele('SymbolPackageFormat', 'snupkg');
114114
propertyGroup.ele('TargetFramework', TARGET_FRAMEWORK);
115+
// Transparently rolll forward across major SDK releases if needed
116+
propertyGroup.ele('RollForward', 'Major');
115117

116118
const itemGroup1 = rootNode.ele('ItemGroup');
117119
const embeddedResource = itemGroup1.ele('EmbeddedResource');

packages/jsii-pacmak/test/generated-code/__snapshots__/examples.test.js.snap

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/jsii-pacmak/test/generated-code/__snapshots__/prerelease-identifiers.test.js.snap

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/jsii-pacmak/test/generated-code/__snapshots__/target-dotnet.test.js.snap

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)