Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 48cfa55

Browse files
committed
dropped net40 target from modern projects
1 parent ab97b02 commit 48cfa55

File tree

10 files changed

+161
-361
lines changed

10 files changed

+161
-361
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ details about the cause of the failure
4141
### Removed
4242

4343
- implicit assembly loading (you have to explicitly `clr.AddReference` before doing import)
44+
- support for .NET Framework 4.0-4.6; Mono before 5.4. Python.NET now requires .NET Standard 2.0
45+
(see [the matrix](https://docs.microsoft.com/en-us/dotnet/standard/net-standard#net-implementation-support))
4446

4547
## [2.5.0][] - 2020-06-14
4648

pythonnet.15.sln

Lines changed: 92 additions & 224 deletions
Large diffs are not rendered by default.

src/clrmodule/clrmodule.15.csproj

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<PropertyGroup>
66
<TargetFrameworks>net40</TargetFrameworks>
77
<Platforms>x64;x86</Platforms>
8-
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
8+
<Configurations>DebugMono;ReleaseMono;DebugWin;ReleaseWin</Configurations>
99
<RootNamespace>clrmodule</RootNamespace>
1010
<AssemblyName>clrmodule</AssemblyName>
1111
<PackageId>clrmodule</PackageId>
@@ -46,29 +46,16 @@
4646
<Optimize>true</Optimize>
4747
<DebugType>pdbonly</DebugType>
4848
</PropertyGroup>
49-
5049
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMono'">
51-
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2;TRACE;DEBUG</DefineConstants>
52-
</PropertyGroup>
53-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMono'">
54-
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2</DefineConstants>
55-
</PropertyGroup>
56-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWin'">
57-
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2;TRACE;DEBUG</DefineConstants>
58-
</PropertyGroup>
59-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWin'">
60-
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON2</DefineConstants>
61-
</PropertyGroup>
62-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugMonoPY3'">
6350
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3;TRACE;DEBUG</DefineConstants>
6451
</PropertyGroup>
65-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMonoPY3'">
52+
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseMono'">
6653
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3</DefineConstants>
6754
</PropertyGroup>
68-
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWinPY3'">
55+
<PropertyGroup Condition=" '$(Configuration)' == 'DebugWin'">
6956
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3;TRACE;DEBUG</DefineConstants>
7057
</PropertyGroup>
71-
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWinPY3'">
58+
<PropertyGroup Condition=" '$(Configuration)' == 'ReleaseWin'">
7259
<DefineConstants Condition="'$(CustomDefineConstants)' == ''">$(DefineConstants);PYTHON3</DefineConstants>
7360
</PropertyGroup>
7461

src/console/Console.15.csproj

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<Project>
22
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
33
<PropertyGroup>
4-
<TargetFrameworks>net40;netcoreapp3.1</TargetFrameworks>
4+
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
55
<Platforms>x64;x86</Platforms>
6-
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
6+
<Configurations>DebugMono;ReleaseMono;DebugWin;ReleaseWin</Configurations>
77
<OutputType>Exe</OutputType>
88
<AssemblyName>nPython</AssemblyName>
99
<RootNamespace>Python.Runtime</RootNamespace>
@@ -16,21 +16,20 @@
1616
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
1717
<GenerateAssemblyDescriptionAttribute>false</GenerateAssemblyDescriptionAttribute>
1818
<OutputPath>bin\</OutputPath>
19-
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net40'">false</AppendTargetFrameworkToOutputPath>
20-
<DocumentationFile Condition="'$(TargetFramework)'=='net40'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
21-
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
19+
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net461'">false</AppendTargetFrameworkToOutputPath>
20+
<DocumentationFile Condition="'$(TargetFramework)'=='net461'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
21+
<DocumentationFile Condition="'$(TargetFramework)'!='net461'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
2222
<NoWarn>1591</NoWarn>
2323
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
2424
<PythonBuildDir Condition=" '$(PythonBuildDir)' == '' ">$(SolutionDir)\bin\</PythonBuildDir>
25-
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(PythonBuildDir)\$(TargetFramework)\</PublishDir>
25+
<PublishDir Condition="'$(TargetFramework)'!='net461'">$(PythonBuildDir)\$(TargetFramework)\</PublishDir>
2626
<LangVersion>6</LangVersion>
2727
<ApplicationIcon>python-clear.ico</ApplicationIcon>
2828
<ErrorReport>prompt</ErrorReport>
2929
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>
3030
<BaseDefineConstants>XPLAT</BaseDefineConstants>
3131
<DefineConstants>$(DefineConstants);$(CustomDefineConstants);$(BaseDefineConstants);</DefineConstants>
3232
<DefineConstants Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(CustomDefineConstants)' != '' AND $(Configuration.Contains('Debug'))">$(DefineConstants);TRACE;DEBUG</DefineConstants>
33-
<FrameworkPathOverride Condition="'$(TargetFramework)'=='net40' AND $(Configuration.Contains('Mono'))">$(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\</FrameworkPathOverride>
3433
</PropertyGroup>
3534
<PropertyGroup Condition=" '$(Platform)' == 'x86'">
3635
<PlatformTarget>x86</PlatformTarget>
@@ -39,11 +38,11 @@
3938
<PlatformTarget>x64</PlatformTarget>
4039
</PropertyGroup>
4140

42-
<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='net40'">
41+
<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='net461'">
4342
<Optimize>false</Optimize>
4443
<DebugType>full</DebugType>
4544
</PropertyGroup>
46-
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='net40'">
45+
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='net461'">
4746
<Optimize>true</Optimize>
4847
<DebugType>pdbonly</DebugType>
4948
</PropertyGroup>
@@ -68,7 +67,7 @@
6867
<PropertyGroup Condition="'$(PythonManifest)' != ''">
6968
<ApplicationManifest>$(PythonManifest)</ApplicationManifest>
7069
</PropertyGroup>
71-
<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
70+
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
7271
<Reference Include="System" />
7372
</ItemGroup>
7473
<ItemGroup>
@@ -78,17 +77,23 @@
7877
</ItemGroup>
7978
<ItemGroup>
8079
<Content Include="python-clear.ico" />
81-
<EmbeddedResource Condition="'$(TargetFramework)'=='net40'" Include="$(PythonBuildDir)\Python.Runtime.dll">
80+
<EmbeddedResource Condition="'$(TargetFramework)'=='net461'" Include="$(PythonBuildDir)\Python.Runtime.dll">
8281
<LogicalName>Python.Runtime.dll</LogicalName>
8382
</EmbeddedResource>
8483
</ItemGroup>
84+
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
85+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
86+
<PrivateAssets>all</PrivateAssets>
87+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
88+
</PackageReference>
89+
</ItemGroup>
8590
<ItemGroup>
8691
<ProjectReference Include="..\runtime\Python.Runtime.15.csproj" />
8792
</ItemGroup>
8893

8994
<Import Project="Sdk.targets" Sdk="Microsoft.NET.Sdk" />
9095

9196
<Target Name="AfterBuild">
92-
<Copy Condition="'$(TargetFramework)'=='net40'" SourceFiles="$(TargetPath)" DestinationFolder="$(PythonBuildDir)" />
97+
<Copy Condition="'$(TargetFramework)'=='net461'" SourceFiles="$(TargetPath)" DestinationFolder="$(PythonBuildDir)" />
9398
</Target>
9499
</Project>

src/console/pythonconsole.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ namespace Python.Runtime
1616
/// </remarks>
1717
public sealed class PythonConsole
1818
{
19-
#if NET40
19+
#if NET461
2020
private static AssemblyLoader assemblyLoader = new AssemblyLoader();
2121
#endif
2222
private PythonConsole()
@@ -26,8 +26,8 @@ private PythonConsole()
2626
[STAThread]
2727
public static int Main(string[] args)
2828
{
29-
// Only net40 is capable to safely inject python.runtime.dll into resources.
30-
#if NET40
29+
// Only .NET Framework is capable to safely inject python.runtime.dll into resources.
30+
#if NET461
3131
// reference the static assemblyLoader to stop it being optimized away
3232
AssemblyLoader a = assemblyLoader;
3333
#endif
@@ -40,7 +40,7 @@ public static int Main(string[] args)
4040
return i;
4141
}
4242

43-
#if NET40
43+
#if NET461
4444
// Register a callback function to load embedded assemblies.
4545
// (Python.Runtime.dll is included as a resource)
4646
private sealed class AssemblyLoader

src/embed_tests/Python.EmbeddingTest.15.csproj

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
<Import Project="Sdk.props" Sdk="Microsoft.NET.Sdk" />
33

44
<PropertyGroup>
5-
<TargetFrameworks>net40;netcoreapp3.1</TargetFrameworks>
5+
<TargetFrameworks>net461;netcoreapp3.1</TargetFrameworks>
66
<Platforms>x64;x86</Platforms>
7-
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
8-
<OutputType Condition="'$(TargetFramework)' != 'net40' OR '$(PYTHONNET_VS_ENV)' == 'true'">Exe</OutputType>
7+
<Configurations>DebugMono;ReleaseMono;DebugWin;ReleaseWin</Configurations>
8+
<OutputType Condition="'$(TargetFramework)' != 'net461' OR '$(PYTHONNET_VS_ENV)' == 'true'">Exe</OutputType>
99
<GenerateProgramFile>false</GenerateProgramFile>
1010
<AssemblyName>Python.EmbeddingTest</AssemblyName>
1111
<RootNamespace>Python.EmbeddingTest</RootNamespace>
@@ -16,13 +16,13 @@
1616
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
1717
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
1818
<OutputPath>bin\</OutputPath>
19-
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net40'">false</AppendTargetFrameworkToOutputPath>
20-
<DocumentationFile Condition="'$(TargetFramework)'=='net40'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
21-
<DocumentationFile Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
19+
<AppendTargetFrameworkToOutputPath Condition="'$(TargetFramework)'=='net461'">false</AppendTargetFrameworkToOutputPath>
20+
<DocumentationFile Condition="'$(TargetFramework)'=='net461'">$(OutputPath)\$(AssemblyName).xml</DocumentationFile>
21+
<DocumentationFile Condition="'$(TargetFramework)'!='net461'">$(OutputPath)\$(TargetFramework)\$(AssemblyName).xml</DocumentationFile>
2222
<NoWarn>1591</NoWarn>
2323
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
24-
<PythonBuildDir Condition="'$(TargetFramework)'=='net40' AND '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
25-
<PublishDir Condition="'$(TargetFramework)'!='net40'">$(OutputPath)\$(TargetFramework)_publish</PublishDir>
24+
<PythonBuildDir Condition="'$(TargetFramework)'=='net461' AND '$(PythonBuildDir)' == ''">$(SolutionDir)\bin\</PythonBuildDir>
25+
<PublishDir Condition="'$(TargetFramework)'!='net461'">$(OutputPath)\$(TargetFramework)_publish</PublishDir>
2626
<LangVersion>7.3</LangVersion>
2727
<ErrorReport>prompt</ErrorReport>
2828
<CustomDefineConstants Condition="'$(CustomDefineConstants)' == ''">$(PYTHONNET_DEFINE_CONSTANTS)</CustomDefineConstants>
@@ -31,7 +31,6 @@
3131
<DefineConstants Condition="'$(TargetFramework)'=='netcoreapp3.1'">$(DefineConstants);NETCOREAPP</DefineConstants>
3232
<DefineConstants Condition="'$(TargetFramework)'=='netstandard2.0'">$(DefineConstants);NETSTANDARD</DefineConstants>
3333
<DefineConstants Condition="'$(BuildingInsideVisualStudio)' == 'true' AND '$(CustomDefineConstants)' != '' AND $(Configuration.Contains('Debug'))">$(DefineConstants);TRACE;DEBUG</DefineConstants>
34-
<FrameworkPathOverride Condition="'$(TargetFramework)'=='net40' AND $(Configuration.Contains('Mono'))">$(NuGetPackageRoot)\microsoft.targetingpack.netframework.v4.5\1.0.1\lib\net45\</FrameworkPathOverride>
3534
</PropertyGroup>
3635
<PropertyGroup Condition=" '$(Platform)' == 'x86'">
3736
<PlatformTarget>x86</PlatformTarget>
@@ -40,11 +39,11 @@
4039
<PlatformTarget>x64</PlatformTarget>
4140
</PropertyGroup>
4241

43-
<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='net40'">
42+
<PropertyGroup Condition="$(Configuration.Contains('Debug')) AND '$(TargetFramework)'=='net461'">
4443
<Optimize>false</Optimize>
4544
<DebugType>full</DebugType>
4645
</PropertyGroup>
47-
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='net40'">
46+
<PropertyGroup Condition="$(Configuration.Contains('Release')) AND '$(TargetFramework)'=='net461'">
4847
<Optimize>true</Optimize>
4948
<DebugType>pdbonly</DebugType>
5049
</PropertyGroup>
@@ -90,11 +89,17 @@
9089
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1'">
9190
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.5.0" />
9291
</ItemGroup>
92+
<ItemGroup Condition="'$(TargetFramework)'=='net461'">
93+
<PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.0">
94+
<PrivateAssets>all</PrivateAssets>
95+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
96+
</PackageReference>
97+
</ItemGroup>
9398
<ItemGroup>
9499
<ProjectReference Include="..\runtime\Python.Runtime.15.csproj" />
95100
</ItemGroup>
96101

97-
<ItemGroup Condition="'$(TargetFramework)' == 'net40'">
102+
<ItemGroup Condition="'$(TargetFramework)' == 'net461'">
98103
<Reference Include="Microsoft.CSharp" />
99104
</ItemGroup>
100105

@@ -114,7 +119,7 @@
114119
</PropertyGroup>
115120

116121
<Target Name="AfterBuild">
117-
<Copy Condition="'$(TargetFramework)'=='net40'" SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
122+
<Copy Condition="'$(TargetFramework)'=='net461'" SourceFiles="$(TargetAssembly)" DestinationFolder="$(PythonBuildDir)" />
118123
<!--Copy SourceFiles="$(TargetAssemblyPdb)" Condition="Exists('$(TargetAssemblyPdb)')" DestinationFolder="$(PythonBuildDir)" /-->
119124
</Target>
120125

src/perf_tests/Python.PerformanceTests.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net461</TargetFramework>
5-
<Configurations>DebugMono;DebugMonoPY3;ReleaseMono;ReleaseMonoPY3;DebugWin;DebugWinPY3;ReleaseWin;ReleaseWinPY3</Configurations>
5+
<Configurations>DebugMono;ReleaseMono;DebugWin;ReleaseWin</Configurations>
66
<OutputPath>bin\</OutputPath>
77

88
<IsPackable>false</IsPackable>
@@ -28,7 +28,7 @@
2828
</ItemGroup>
2929

3030
<Target Name="GetRuntimeLibBuildOutput" BeforeTargets="Build">
31-
<MSBuild Projects="..\runtime\Python.Runtime.15.csproj" Properties="PYTHONNET_PY3_VERSION=PYTHON38;Configuration=$(Configuration);TargetFramework=net40;Python3Version=PYTHON38;OutputPath=bin\for_perf\">
31+
<MSBuild Projects="..\runtime\Python.Runtime.15.csproj" Properties="PYTHONNET__VERSION=PYTHON38;Configuration=$(Configuration);Python3Version=PYTHON38;OutputPath=bin\for_perf\">
3232
<Output TaskParameter="TargetOutputs" ItemName="NewPythonRuntime" />
3333
</MSBuild>
3434
</Target>

0 commit comments

Comments
 (0)