Skip to content

Commit

Permalink
Do not force TargetFramework when building projects
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubfijalkowski committed Dec 12, 2022
1 parent 6d62f6a commit 5702c6f
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 20 deletions.
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 5702c6f

Please sign in to comment.