Skip to content

Commit

Permalink
Merge pull request #127 from leancodepl/net6-binary
Browse files Browse the repository at this point in the history
Allow building .NET 7 projects with .NET 6 binary
  • Loading branch information
jakubfijalkowski authored Dec 12, 2022
2 parents 2984222 + 5702c6f commit bbec17c
Show file tree
Hide file tree
Showing 10 changed files with 9 additions and 21 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ jobs:
env:
BUILD_VERSION: ${{ steps.get_version.outputs.version }}
working-directory: src/LeanCode.ContractsGenerator
run: dotnet publish --output ./publish --no-self-contained --no-build --configuration Release
run: dotnet publish --output ./publish --no-self-contained --no-build --configuration Release --framework net6.0
- name: Pack
env:
BUILD_VERSION: ${{ steps.get_version.outputs.version }}
Expand Down
2 changes: 1 addition & 1 deletion examples/project/aggregated/A/A.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/project/aggregated/B/B.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/project/aggregated/Combined/Combined.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/project/embedded/embedded.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion examples/project/implicitusings/implicitusings.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

Expand Down
2 changes: 1 addition & 1 deletion examples/project/packagereference/packagereference.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<Target Name="BuildDependencies" BeforeTargets="Restore">
Expand Down
2 changes: 1 addition & 1 deletion examples/project/single/single.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net6.0;net7.0</TargetFrameworks>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@ namespace LeanCode.ContractsGenerator.Compilation.MSBuild;

public static class MSBuildHelper
{
private const string FrameworkMoniker =
#if NET6_0
"net6.0";
#elif NET7_0
"net7.0";
#else
#error TargetFramework property mismatch between project and code.
#endif
private static readonly string[] RestoreTarget = new string[] { "Restore" };

private static readonly ImmutableDictionary<string, string> GlobalProperties = ImmutableDictionary.CreateRange(new Dictionary<string, string>
Expand All @@ -33,9 +25,6 @@ public static class MSBuildHelper

// Use the preview language version to force the full set of available analyzers to run on the project.
["LangVersion"] = "preview",

["TargetFrameworks"] = FrameworkMoniker,
["TargetFramework"] = FrameworkMoniker,
});

static MSBuildHelper()
Expand Down Expand Up @@ -100,7 +89,6 @@ public static int RestoreProjects(

if (!projectInstance.Targets.ContainsKey("_IsProjectRestoreSupported"))
{
System.Console.WriteLine("No _IsProjectRestoreSupported");
continue;
}

Expand Down

0 comments on commit bbec17c

Please sign in to comment.