Commit 2c6fb9cf authored by Yeechan Lu's avatar Yeechan Lu

Initial commit

parents
Pipeline #3 skipped
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{E6975A7A-37A4-44E3-8BB7-D0EE939B4189}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Demo</RootNamespace>
<AssemblyName>Demo</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup>
<StartupObject />
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<ItemGroup>
<Reference Include="RGiesecke.DllExport.Metadata">
<HintPath>..\packages\UnmanagedExports.1.2.6\lib\net\RGiesecke.DllExport.Metadata.dll</HintPath>
<Private>False</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="NativeMethods.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
<SubType>Designer</SubType>
</EmbeddedResource>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Resources.resx</DependentUpon>
<DesignTime>True</DesignTime>
</Compile>
<None Include="app.config" />
<None Include="app.json" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="../packages/UnmanagedExports.1.2.6/tools/RGiesecke.DllExport.targets" Condition="Exists('../packages/UnmanagedExports.1.2.6/tools/RGiesecke.DllExport.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Demo
{
static class NativeMethods
{
[DllImport("CQP.dll")]
public static extern Int32 CQ_addLog(Int32 authCode, Int32 level, [MarshalAs(UnmanagedType.LPStr)] String category, [MarshalAs(UnmanagedType.LPStr)] String message);
[DllImport("CQP.dll")]
public static extern Int32 CQ_sendPrivateMsg(Int32 authCode, Int64 dest, [MarshalAs(UnmanagedType.LPStr)] String message);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using RGiesecke.DllExport;
using System.Runtime.InteropServices;
using System.Threading;
namespace Demo
{
static class Program
{
static Int32 AuthCode;
[return: MarshalAs(UnmanagedType.LPStr)]
[DllExport()]
public static String AppInfo() {
return "9,wtf.demo.echo";
}
[DllExport()]
public static Int32 Initialize(Int32 authCode)
{
AuthCode = authCode;
return 0;
}
[DllExport()]
public static Int32 eventStartup()
{
NativeMethods.CQ_addLog(AuthCode, 10, "裤衩", "你好裤衩,这里是木馨!");
return 0;
}
[DllExport()]
public unsafe static Int32 eventPrivateMsg(Int32 subType, Int32 sendTime, Int64 fromQQ, [MarshalAs(UnmanagedType.LPStr)] String message, Int32 font)
{
string x = message;
ThreadPool.QueueUserWorkItem(delegate(Object _)
{
NativeMethods.CQ_sendPrivateMsg(AuthCode, fromQQ, x);
});
return 0;
}
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("Demo")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Demo")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("875d3fee-b072-485a-8d64-4e4888509767")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.33440
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Demo.Properties {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Demo.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.33440
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace Demo.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/></startup></configuration>
{
"ret": 1,
"apiver": 9,
"appid": "wtf.demo.echo",
"name": "C# Echo",
"version": "1.0.0",
"version_id": 1,
"author": "orzFly",
"description": "来自 .NET 的回显。",
"event": [
{
"id": 1001,
"type": 1001,
"name": "酷Q启动事件",
"priority": 30000,
"function": "eventStartup"
},
{
"id": 21,
"type": 21,
"name": "私聊消息处理",
"function": "eventPrivateMsg",
"priority": 30000
}
],
"menu": [
],
"status": [
],
"auth": [
100,
101,
102,
103,
104,
106,
110,
120,
121,
122,
123,
124,
125,
126,
130,
131,
140,
150,
151
]
}
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="UnmanagedExports" version="1.2.6" targetFramework="net45" />
</packages>
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.31101.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Demo", "Demo\Demo.csproj", "{E6975A7A-37A4-44E3-8BB7-D0EE939B4189}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x86 = Debug|x86
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{E6975A7A-37A4-44E3-8BB7-D0EE939B4189}.Debug|x86.ActiveCfg = Debug|x86
{E6975A7A-37A4-44E3-8BB7-D0EE939B4189}.Debug|x86.Build.0 = Debug|x86
{E6975A7A-37A4-44E3-8BB7-D0EE939B4189}.Release|x86.ActiveCfg = Release|x86
{E6975A7A-37A4-44E3-8BB7-D0EE939B4189}.Release|x86.Build.0 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
function Remove-OldDllExportFolder {
param($project)
$defaultFiles = ('DllExportAttribute.cs',
'Mono.Cecil.dll',
'RGiesecke.DllExport.dll',
'RGiesecke.DllExport.pdb',
'RGiesecke.DllExport.MSBuild.dll',
'RGiesecke.DllExport.MSBuild.pdb',
'RGiesecke.DllExport.targets')
$projectFile = New-Object 'System.IO.FileInfo'($project.FullName)
$projectFile.Directory.GetDirectories("DllExport") | Select-Object -First 1 | % {
$dllExportDir = $_
if($dllExportDir.GetDirectories().Count -eq 0){
$unknownFiles = $dllExportDir.GetFiles() | Select -ExpandProperty Name | ? { -not $defaultFiles -contains $_ }
if(-not $unknownFiles){
Write-Host "Removing 'DllExport' from " $project.Name
$project.ProjectItems | ? { $_.Name -ieq 'DllExport' } | % {
$_.Remove()
}
Write-Host "Deleting " $dllExportDir.FullName " ..."
$dllExportDir.Delete($true)
}
}
}
}
function Remove-OldDllExportFolders {
Get-Project -all | % {
Remove-OldDllExportFolder $_
}
}
function Get-DllExportMsBuildProjectsByFullName([String] $fullName) {
$msBuildV4Name = 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a';
$msBuildV4 = [System.Reflection.Assembly]::LoadWithPartialName($msBuildV4Name)
if(!$msBuildV4) {
throw New-Object 'System.IO.FileNotFoundException'("Could not load $msBuildV4Name.")
}
$projectCollection = $msBuildV4.GetType('Microsoft.Build.Evaluation.ProjectCollection')
return $projectCollection::GlobalProjectCollection.GetLoadedProjects($fullName)
}
function Get-AllDllExportMsBuildProjects {
(Get-Project -all | % {
Get-DllExportMsBuildProjectsByFullName $_.FullName
}) | ? {
return ($_.Xml.Imports | ? {
"RGiesecke.DllExport.targets" -ieq [System.IO.Path]::GetFileName($_.Project);
}).Length -gt 0;
}
}
function Assert-PlatformTargetOfProject([String] $fullName) {
$proj = Get-DllExportMsBuildProjectsByFullName $fullName
if(!$proj) {
return;
}
$platformTarget = $proj.GetPropertyValue('PlatformTarget');
if(!$platformTarget -or ($platformTarget -ine 'x86' -and $platformTarget -ine 'x64')) {
$projectName = [IO.Path]::GetFileNameWithoutExtension($fullName);
if(!$platformTarget) {
$platformTarget = "has no platform target";
} else {
$platformTarget = "has a platform target of '$platformTarget'";
}
Write-Warning "The project '$projectName' $platformTarget. Only x86 or x64 assemblies can export functions."
Write-Host ""
}
}
function Set-NoDllExportsForAnyCpu([String] $projectName, [System.Nullable[bool]] $value) {
$projects = Get-AllDllExportMsBuildProjects;
[String] $asString = $value;
if($projectName) {
$projects = $projects | where { $_.Name -ieq $projectName };
}
$propertyName = 'NoDllExportsForAnyCpu';
$projects = $projects | where {
$_.GetPropertyValue($propertyName) -ine $asString
} | % {
$_.SetProperty($propertyName, $asString);
}
}
Export-ModuleMember Set-NoDllExportsForAnyCpu
Export-ModuleMember Remove-OldDllExportFolder
Export-ModuleMember Remove-OldDllExportFolders
Export-ModuleMember Get-DllExportMsBuildProjectsByFullName
Export-ModuleMember Get-AllDllExportMsBuildProjects
Export-ModuleMember Assert-PlatformTargetOfProject
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<PostBuildEventDependsOn>
$(PostBuildEventDependsOn);
RGieseckeDllExport
</PostBuildEventDependsOn>
</PropertyGroup>
<PropertyGroup>
<BuildDependsOn>
$(BuildDependsOn);
RGieseckeDllExport
</BuildDependsOn>
</PropertyGroup>
<UsingTask TaskName="RGiesecke.DllExport.MSBuild.DllExportAppDomainIsolatedTask"
AssemblyFile="RGiesecke.DllExport.MSBuild.dll" />
<Target Name="RGieseckeDllExport"
DependsOnTargets="GetFrameworkPaths">
<!--
These properties can still be applied to the task, but upon installation of a
new version of the nuget package, the properties
DllExportAttributeAssemblyName and DllExportAttributeAssemblyName will be removed from the project.
So, if you want to provide an alternative attribute name, the you have to name the property in your project file differently.
e.g.:
DllExportAttributeAssemblyName="$(MyDllExportAttributeAssemblyName)"
DllExportAttributeFullName="$(MyDllExportAttributeFullName)"
-->
<PropertyGroup>
<DllExportLeaveIntermediateFiles Condition="'$(DllExportLeaveIntermediateFiles)'==''">
false
</DllExportLeaveIntermediateFiles>
</PropertyGroup>
<DllExportAppDomainIsolatedTask Platform="$(Platform)"
PlatformTarget="$(PlatformTarget)"
CpuType="$(CpuType)"
EmitDebugSymbols="$(DebugSymbols)"
LeaveIntermediateFiles="$(DllExportLeaveIntermediateFiles)"
Timeout="$(DllExportTimeout)"
KeyContainer="$(KeyContainerName)$(AssemblyKeyContainerName)"
KeyFile="$(KeyOriginatorFile)"
ProjectDirectory="$(MSBuildProjectDirectory)"
InputFileName="$(TargetPath)"
FrameworkPath="$(TargetedFrameworkDir);$(TargetFrameworkDirectory)"
LibToolPath="$(DevEnvDir)\..\..\VC\bin"
LibToolDllPath="$(DevEnvDir)"
TargetFrameworkVersion="$(TargetFrameworkVersion)"
SdkPath="$(TargetFrameworkSDKToolsDirectory)"
SkipOnAnyCpu="$(NoDllExportsForAnyCpu)"/>
</Target>
</Project>
\ No newline at end of file
param($installPath, $toolsPath, $package, $project)
Import-Module (Join-Path $toolsPath DllExportCmdLets.psm1)
if($project) {
Assert-PlatformTargetOfProject $project.FullName
}
else {
Get-AllDllExportMsBuildProjects | % {
Assert-PlatformTargetOfProject $_.FullPath
}
}
\ No newline at end of file
param($installPath, $toolsPath, $package, $project)
$targetFileName = 'RGiesecke.DllExport.targets'
$targetFileName = [IO.Path]::Combine($toolsPath, $targetFileName)
$targetUri = New-Object Uri -ArgumentList $targetFileName, [UriKind]::Absolute
$msBuildV4Name = 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a';
$msBuildV4 = [System.Reflection.Assembly]::LoadWithPartialName($msBuildV4Name)
if(!$msBuildV4) {
throw New-Object System.IO.FileNotFoundException("Could not load $msBuildV4Name.");
}
$projectCollection = $msBuildV4.GetType('Microsoft.Build.Evaluation.ProjectCollection')
# change the reference to RGiesecke.DllExport.Metadata.dll to not be copied locally
$project.Object.References | ? {
$_.Name -ieq "RGiesecke.DllExport.Metadata"
} | % {
if($_ | Get-Member | ? {$_.Name -eq "CopyLocal"}){
$_.CopyLocal = $false
}
}
$projects = $projectCollection::GlobalProjectCollection.GetLoadedProjects($project.FullName)
$projects | % {
$currentProject = $_
# remove imports of RGiesecke.DllExport.targets from this project
$currentProject.Xml.Imports | ? {
return ("RGiesecke.DllExport.targets" -ieq [IO.Path]::GetFileName($_.Project))
} | % {
$currentProject.Xml.RemoveChild($_);
}
# remove the properties DllExportAttributeFullName and DllExportAttributeAssemblyName
$currentProject.Xml.Properties | ? {
$_.Name -eq "DllExportAttributeFullName" -or $_.Name -eq "DllExportAttributeAssemblyName"
} | % {
$_.Parent.RemoveChild($_)
}
$projectUri = New-Object Uri