Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/Traversal.UnitTests/TraversalTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,15 @@ public void PropertiesAreSet(string target)
[InlineData("RestoreProjectStyle", null, "PackageReference")]
[InlineData("StopOnFirstFailure", "false", "false")]
[InlineData("StopOnFirstFailure", null, "true")]
#if NETFRAMEWORK || NET9_0 // These map how MSBuild.ProjectCreation chooses SDK versions given the TFM of the test
[InlineData("TargetFramework", "net6.0", "net6.0")]
[InlineData("TargetFramework", null, "net45")]
[InlineData("TargetFramework", null, "net9.0")]
#elif NET8_0
[InlineData("TargetFramework", "net6.0", "net6.0")]
[InlineData("TargetFramework", null, "net8.0")]
#else
#error "Update test data for the given target framework"
#endif
[InlineData("TraversalProjectNames", "custom.proj", "custom.proj")]
[InlineData("TraversalProjectNames", null, "dirs.proj")]
[InlineData("UsingMicrosoftTraversalSdk", null, "true")]
Expand Down
7 changes: 5 additions & 2 deletions src/Traversal/Sdk/Traversal.targets
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,12 @@
<EnableDefaultItems>false</EnableDefaultItems>

<!--
TargetFramework is required for restore and used to default to .NET Framework v4.5. However, Traversal projects don't specify a version so it needs to be defaulted here.
TargetFramework is required for restore. If the user specifies a version, use that. Otherwise, use the
NETCoreAppMaximumVersion so that the project acts as if it were part of the SDK. If for some reason that's also
not set, fallback to the SDK's old default of .NET Framework v4.5.
-->
<TargetFramework Condition="'$(TargetFramework)' == ''">net45</TargetFramework>
<TargetFramework Condition=" '$(TargetFramework)' == '' And '$(NETCoreAppMaximumVersion)' != ''">net$(NETCoreAppMaximumVersion)</TargetFramework>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about something like netstandard1.0 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be an improvement over net45, but it doesn't fix the linked bug.

Targeting old netstandard means we're still opt-ed out of modern defaults like defaulting to Release for publish and pack.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another alternative would be to find a solution for the project templates. Then we could default to the current SDK version in the template.

I also prefer that option a bit less since it means every Traversal would set the TFM which clutters things a bit, but it'd be less magical.

<TargetFramework Condition=" '$(TargetFramework)' == ''">net45</TargetFramework>
</PropertyGroup>

<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
Expand Down
2 changes: 1 addition & 1 deletion src/Traversal/version.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"inherit": true,
"version": "4.1"
"version": "5.0"
}