Skip to content

Commit 74e178c

Browse files
author
Barton Cline
committed
# Visual Studio 2010 .NET 4.0 (with a little ReSharper thrown in) #
# The new C# clrmodule depends on RGiesecke.DllExport in new pythonnet/packages directory which was import via NuGet # # The signing key finally landed in the correct directory # # Not sure why the console/Console.csproj referenced Python.Test # # Python.Runtime Assembly version bumped to 4.0.0.1 # # Tool and Framework versions all bumped for .NET 4.0 # # [Obsolete?] buildclrmodule.bat got a tiny note after cli research on clrmodule.il # # EmbeddingTest remains in flux while issues with nUnit (version bump) get ironed out #
1 parent 53b6f30 commit 74e178c

24 files changed

+489
-31
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0"?>
2+
<package xmlns="http://schemas.microsoft.com/packaging/2011/10/nuspec.xsd">
3+
<metadata>
4+
<id>UnmanagedExports</id>
5+
<version>1.2.3-Beta</version>
6+
<title>Unmanaged Exports (DllExport for .Net)</title>
7+
<authors>Robert Giesecke</authors>
8+
<owners>Robert Giesecke</owners>
9+
<licenseUrl>http://opensource.org/licenses/mit-license.php</licenseUrl>
10+
<projectUrl>https://sites.google.com/site/robertgiesecke/Home/uploads/unmanagedexports</projectUrl>
11+
<requireLicenseAcceptance>false</requireLicenseAcceptance>
12+
<description>A set of compile-time libraries (nothing to deploy) and a build task that enable you to export functions from managed code to native applications.
13+
That means, you can create plugins in a managed language like C# or F# for native applications that only have a C-Api (like Notepad++).
14+
The nuget package is all you need. Just mark your methods with [DllExport] and build.
15+
16+
Hints:
17+
- You have to set your platform target to either x86, ia64 or x64. AnyCPU assemblies cannot export functions.
18+
- The export name defaults to the method name and the calling convention to stdcall. If that's all what you want, you can just use [DllExport] without parameters.
19+
- You cannot put your exports in generic types or export gegenric methods, but your parameters or the result can use generics.
20+
e.g.:
21+
[DllExport]
22+
static void Test(YourStruct&lt;int&gt; data){}</description>
23+
<summary>Adds the ability to declare unmanaged function exports.
24+
IOW: the exact opposite of how DllImport works.</summary>
25+
<releaseNotes>- Placing [DllExport] on non-static methods will now yield an error.
26+
- Placing [DllExport] on methods in generic types (or types nested in generic types) will yield an error.
27+
- Errors regarding lib.exe will no longer break the build.
28+
- Added support for generic return types. Even the most esotheric corner cases (obfuscated types) should work.
29+
- Made the code that checks method names and class names much more resilient and faster.
30+
- Most messages are localizable now (and I translated them to German).</releaseNotes>
31+
<language>en-US</language>
32+
<tags>dllexport unmanaged exports export</tags>
33+
<references>
34+
<reference file="RGiesecke.DllExport.Metadata.dll" />
35+
</references>
36+
</metadata>
37+
</package>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
function Remove-OldDllExportFolder
2+
{
3+
param($project)
4+
$defaultFiles = ('DllExportAttribute.cs',
5+
'Mono.Cecil.dll',
6+
'RGiesecke.DllExport.dll',
7+
'RGiesecke.DllExport.pdb',
8+
'RGiesecke.DllExport.MSBuild.dll',
9+
'RGiesecke.DllExport.MSBuild.pdb',
10+
'RGiesecke.DllExport.targets')
11+
12+
$projectFile = New-Object IO.FileInfo($project.FullName)
13+
14+
$projectFile.Directory.GetDirectories("DllExport") | Select-Object -First 1 | % {
15+
$dllExportDir = $_
16+
17+
if($dllExportDir.GetDirectories().Count -eq 0){
18+
$unknownFiles = $dllExportDir.GetFiles() | Select -ExpandProperty Name | ? { -not $defaultFiles -contains $_ }
19+
20+
if(-not $unknownFiles){
21+
Write-Host "Removing 'DllExport' from " $project.Name
22+
$project.ProjectItems | ? { $_.Name -eq 'DllExport' } | % {
23+
$_.Remove()
24+
}
25+
26+
Write-Host "Deleting " $dllExportDir.FullName " ..."
27+
$dllExportDir.Delete($true)
28+
}
29+
}
30+
}
31+
}
32+
33+
function Remove-OldDllExportFolders
34+
{
35+
Get-Project -all | % {
36+
Remove-OldDllExportFolder $_
37+
}
38+
}
39+
40+
Export-ModuleMember Remove-OldDllExportFolder
41+
Export-ModuleMember Remove-OldDllExportFolders
Binary file not shown.
Binary file not shown.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
4+
<PropertyGroup>
5+
<PostBuildEventDependsOn>
6+
$(PostBuildEventDependsOn);
7+
RGieseckeDllExport
8+
</PostBuildEventDependsOn>
9+
</PropertyGroup>
10+
11+
<PropertyGroup>
12+
<BuildDependsOn>
13+
$(BuildDependsOn);
14+
RGieseckeDllExport
15+
</BuildDependsOn>
16+
</PropertyGroup>
17+
18+
<UsingTask TaskName="RGiesecke.DllExport.MSBuild.DllExportAppDomainIsolatedTask"
19+
AssemblyFile="RGiesecke.DllExport.MSBuild.dll" />
20+
21+
<Target Name="RGieseckeDllExport"
22+
DependsOnTargets="GetFrameworkPaths">
23+
24+
<!--
25+
These properties can still be applied to the task, but upon installation of a
26+
new version of the nuget package, the properties
27+
DllExportAttributeAssemblyName and DllExportAttributeAssemblyName will be removed from the project.
28+
So, if you want to provide an alternative attribute name, the you have to name the property in your project file differently.
29+
30+
e.g.:
31+
DllExportAttributeAssemblyName="$(MyDllExportAttributeAssemblyName)"
32+
DllExportAttributeFullName="$(MyDllExportAttributeFullName)"
33+
-->
34+
35+
36+
<DllExportAppDomainIsolatedTask Platform="$(Platform)"
37+
PlatformTarget="$(PlatformTarget)"
38+
CpuType="$(CpuType)"
39+
EmitDebugSymbols="$(DebugSymbols)"
40+
Timeout="$(DllExportTimeout)"
41+
KeyContainer="$(KeyContainerName)$(AssemblyKeyContainerName)"
42+
KeyFile="$(KeyOriginatorFile)"
43+
ProjectDirectory="$(MSBuildProjectDirectory)"
44+
InputFileName="$(TargetPath)"
45+
FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)"
46+
LibToolPath="$(DevEnvDir)\..\..\VC\bin"
47+
LibToolDllPath="$(DevEnvDir)"
48+
TargetFrameworkVersion="$(TargetFrameworkVersion)"
49+
SdkPath="$(TargetFrameworkSDKToolsDirectory)"
50+
SkipOnAnyCpu="$(NoDllExportsForAnyCpu)"/>
51+
</Target>
52+
</Project>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
param($installPath, $toolsPath, $package, $project)
2+
3+
Import-Module (Join-Path $toolsPath DllExportCmdLets.psm1)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
param($installPath, $toolsPath, $package, $project)
2+
3+
$targetFileName = 'RGiesecke.DllExport.targets'
4+
$targetFileName = [IO.Path]::Combine($toolsPath, $targetFileName)
5+
$targetUri = New-Object Uri -ArgumentList $targetFileName, [UriKind]::Absolute
6+
7+
Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
8+
9+
# change the reference to RGiesecke.DllExport.Metadata.dll to not be copied locally
10+
11+
$project.Object.References | ? {
12+
$_.Name -eq "RGiesecke.DllExport.Metadata"
13+
} | % {
14+
if($_ | Get-Member | ? {$_.Name -eq "CopyLocal"}){
15+
$_.CopyLocal = $false
16+
}
17+
}
18+
19+
$projects = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection.GetLoadedProjects($project.FullName)
20+
$projects | % {
21+
$currentProject = $_
22+
23+
# remove imports of RGiesecke.DllExport.targets from this project
24+
$currentProject.Xml.Imports | ? {
25+
return ("RGiesecke.DllExport.targets" -eq [IO.Path]::GetFileName($_.Project))
26+
} | % {
27+
$currentProject.Xml.RemoveChild($_);
28+
}
29+
30+
# remove the properties DllExportAttributeFullName and DllExportAttributeAssemblyName
31+
$currentProject.Xml.Properties | ? {
32+
$_.Name -eq "DllExportAttributeFullName" -or $_.Name -eq "DllExportAttributeAssemblyName"
33+
} | % {
34+
$_.Parent.RemoveChild($_)
35+
}
36+
37+
$projectUri = New-Object Uri -ArgumentList $currentProject.FullPath, [UriKind]::Absolute
38+
$relativeUrl = $projectUri.MakeRelative($targetUri)
39+
[Void]$currentProject.Xml.AddImport($relativeUrl)
40+
41+
# remove the old stuff in the DllExports folder from previous versions, (will check that only known files are in it)
42+
Remove-OldDllExportFolder $project
43+
}

0 commit comments

Comments
 (0)