Skip to content

Commit

Permalink
fix(dotnet): target netcoreapp3.1 with RollForward (#3987)
Browse files Browse the repository at this point in the history
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).
  • Loading branch information
RomainMuller committed Mar 6, 2023
1 parent 4cbe699 commit 461446b
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ public void OptionalAndVariadicArgumentsTest()
[Fact(DisplayName = Prefix + nameof(JsiiAgentIsCorrect))]
public void JsiiAgentIsCorrect()
{
Assert.Equal("DotNet/" + Environment.Version + "/.NETCoreApp,Version=v6.0/1.0.0.0", JsiiAgent.Value);
Assert.Equal("DotNet/" + Environment.Version + "/.NETCoreApp,Version=v3.1/1.0.0.0", JsiiAgent.Value);
}

[Fact(DisplayName = Prefix + nameof(ReceiveInstanceOfPrivateClass))]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<Import Project="../NuGet.Metadata.props" />

<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework>netcoreapp3.1</TargetFramework>
<RollForward>Major</RollForward>
<PackageId>Amazon.JSII.Runtime</PackageId>
<Title>.NET Runtime for JSII</Title>
<PackageIcon>icon.png</PackageIcon>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ void CacheTypes(Assembly assembly)
}
}

return e.Types;
return e.Types ?? Array.Empty<Type?>();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/jsii-pacmak/lib/targets/dotnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { toReleaseVersion } from './version-utils';

import { TargetName } from '.';

export const TARGET_FRAMEWORK = 'net6.0';
export const TARGET_FRAMEWORK = 'netcoreapp3.1';

/**
* Build .NET packages all together, by generating an aggregate solution file
Expand Down
2 changes: 2 additions & 0 deletions packages/jsii-pacmak/lib/targets/dotnet/filegenerator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ export class FileGenerator {
propertyGroup.ele('Nullable', 'enable');
propertyGroup.ele('SymbolPackageFormat', 'snupkg');
propertyGroup.ele('TargetFramework', TARGET_FRAMEWORK);
// Transparently rolll forward across major SDK releases if needed
propertyGroup.ele('RollForward', 'Major');

const itemGroup1 = rootNode.ele('ItemGroup');
const embeddedResource = itemGroup1.ele('EmbeddedResource');
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 461446b

Please sign in to comment.