Skip to content

Commit

Permalink
Merge pull request #213 from endercrest/full-x86-and-x64-support
Browse files Browse the repository at this point in the history
Full x86 and x64 support (net45)
  • Loading branch information
devkanro authored Jun 11, 2017
2 parents beb2f8e + d550b44 commit aecf57c
Show file tree
Hide file tree
Showing 8 changed files with 242 additions and 5 deletions.
78 changes: 78 additions & 0 deletions Meta.Vlc.Wpf/tools/net45/Install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
param($installPath, $toolsPath, $package, $project)

$allowedReferences = @("Meta.Vlc.Wpf, Version=16.5.1.0, Culture=neutral, processorArchitecture=x86")

# Full assembly name is required
Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

$projectCollection = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection

$allProjects = $projectCollection.GetLoadedProjects($project.Object.Project.FullName).GetEnumerator();

if($allProjects.MoveNext())
{
$currentProject = $allProjects.Current

Write-Host "Current Project $currentProject"

foreach($Reference in $currentProject.GetItems('Reference') | ? {$allowedReferences -contains $_.Xml.Include })
{
$hintPath = $Reference.GetMetadataValue("HintPath")

Write-Host "Matched againt $hintPath"

#If it is x64 specific add condition (Include 'Any Cpu' as x64)
if ($hintPath -match '.*\\(amd64|x64)\\.*\.dll$')
{
$Reference.Xml.Condition = "'TargetPlatform' != 'x86'"

$condition = $Reference.Xml.Condition
Write-Host "hintPath = $hintPath"
Write-Host "condition = $condition"

#Visual Studio doesnt allow the same reference twice (so try add friends)
$matchingReferences = $currentProject.GetItems('Reference') | ? {($_.Xml.Include -eq $Reference.Xml.Include) -and ($_.GetMetadataValue("HintPath") -match ".*\\(x86)\\.*\.dll$")}

#Add x86 Conditional
Write-Host "Adding reference to $x86"

$x86 = $hintPath -replace '(.*\\)(amd64|x64)(\\.*\.dll)$', '$1x86$3'
$x86Path = Join-Path $installPath $x86

$metaData = new-object "System.Collections.Generic.Dictionary``2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
$metaData.Add("HintPath", $x86)
$currentProject.AddItem('Reference', $Reference.Xml.Include, $metaData)

$newReference = $currentProject.GetItems('Reference') | ? {($_.Xml.Include -eq $Reference.Xml.Include) -and ($_.GetMetadataValue("HintPath") -eq $x86)} | Select-Object -First 1

$newReference.Xml.Condition = "'TargetPlatform' == 'x86'"
}

#If it is x86 specific add condition
if ($hintPath -match '.*\\x86\\.*\.dll$')
{
$Reference.Xml.Condition = "'TargetPlatform' == 'x86'"

$condition = $Reference.Xml.Condition
Write-Host "hintPath = $hintPath"
Write-Host "condition = $condition"

#Visual Studio doesnt allow the same reference twice (so try add friends)
$matchingReferences = $currentProject.GetItems('Reference') | ? {($_.Xml.Include -eq $Reference.Xml.Include) -and ($_.GetMetadataValue("HintPath") -match ".*\\(amd64|x64)\\.*\.dll$")}

#Add x64 Specific
$x64 = $hintPath -replace '(.*\\)(x86)(\\.*\.dll)$', '$1x64$3'
$x64Path = Join-Path $installPath $

Write-Host "Adding reference to $x64"

$metaData = new-object "System.Collections.Generic.Dictionary``2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
$metaData.Add("HintPath", $x64)
$currentProject.AddItem('Reference', $Reference.Xml.Include, $metaData)

$newReference = $currentProject.GetItems('Reference') | ? {($_.Xml.Include -eq $Reference.Xml.Include) -and ($_.GetMetadataValue("HintPath") -eq $x64)} | Select-Object -First 1

$newReference.Xml.Condition = "'TargetPlatform' != 'x86'"
}
}
}
18 changes: 18 additions & 0 deletions Meta.Vlc.Wpf/tools/net45/Uninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
param($installPath, $toolsPath, $package, $project)

$allowedReferences = @("Meta.Vlc.Wpf, Version=16.5.1.0, Culture=neutral, processorArchitecture=x86")

# Full assembly name is required
Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

$projectCollection = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection

$allProjects = $projectCollection.GetLoadedProjects($project.Object.Project.FullName).GetEnumerator();

if($allProjects.MoveNext())
{
foreach($Reference in $allProjects.Current.GetItems('Reference') | ? {$allowedReferences -contains $_.UnevaluatedInclude })
{
$allProjects.Current.RemoveItem($Reference)
}
}
26 changes: 26 additions & 0 deletions Meta.Vlc.sln
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
README.md = README.md
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Meta.Vlc", "Meta.Vlc", "{1F316403-9E84-4202-86D1-DC73CC85385C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{FBBD13BC-A4D4-4AFC-83EC-A557D3A83395}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net45", "net45", "{B9E3EF33-8C3B-431F-8C3A-44F23292F67C}"
ProjectSection(SolutionItems) = preProject
Meta.Vlc\tools\net45\Install.ps1 = Meta.Vlc\tools\net45\Install.ps1
Meta.Vlc\tools\net45\Uninstall.ps1 = Meta.Vlc\tools\net45\Uninstall.ps1
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Meta.Vlc.Wpf", "Meta.Vlc.Wpf", "{9E0C4C85-FFFE-4C76-8FA2-13CD1D3A1E2D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tools", "tools", "{F187CDF1-24B3-41E2-AD62-57CB67AB1037}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "net45", "net45", "{CBF6B603-6440-4DD8-93BA-9B489AF23BCD}"
ProjectSection(SolutionItems) = preProject
Meta.Vlc.Wpf\tools\net45\Install.ps1 = Meta.Vlc.Wpf\tools\net45\Install.ps1
Meta.Vlc.Wpf\tools\net45\Uninstall.ps1 = Meta.Vlc.Wpf\tools\net45\Uninstall.ps1
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -209,5 +229,11 @@ Global
{D4CB3A9B-5257-4011-8B81-CF4FBF1B088D} = {F15C4A88-99E0-4C19-AC4D-AA76602B38C0}
{9DDC048A-6053-4639-B054-DCCCD14E1EF8} = {F15C4A88-99E0-4C19-AC4D-AA76602B38C0}
{F945C93E-61B8-4144-9C12-D01D7C4E6F8E} = {F15C4A88-99E0-4C19-AC4D-AA76602B38C0}
{1F316403-9E84-4202-86D1-DC73CC85385C} = {5F789D71-29F8-43F0-9A0F-598400400332}
{FBBD13BC-A4D4-4AFC-83EC-A557D3A83395} = {1F316403-9E84-4202-86D1-DC73CC85385C}
{B9E3EF33-8C3B-431F-8C3A-44F23292F67C} = {FBBD13BC-A4D4-4AFC-83EC-A557D3A83395}
{9E0C4C85-FFFE-4C76-8FA2-13CD1D3A1E2D} = {5F789D71-29F8-43F0-9A0F-598400400332}
{F187CDF1-24B3-41E2-AD62-57CB67AB1037} = {9E0C4C85-FFFE-4C76-8FA2-13CD1D3A1E2D}
{CBF6B603-6440-4DD8-93BA-9B489AF23BCD} = {F187CDF1-24B3-41E2-AD62-57CB67AB1037}
EndGlobalSection
EndGlobal
78 changes: 78 additions & 0 deletions Meta.Vlc/tools/net45/Install.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
param($installPath, $toolsPath, $package, $project)

$allowedReferences = @("Meta.Vlc, Version=16.5.1.0, Culture=neutral, processorArchitecture=x86")

# Full assembly name is required
Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

$projectCollection = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection

$allProjects = $projectCollection.GetLoadedProjects($project.Object.Project.FullName).GetEnumerator();

if($allProjects.MoveNext())
{
$currentProject = $allProjects.Current

Write-Host "Current Project $currentProject"

foreach($Reference in $currentProject.GetItems('Reference') | ? {$allowedReferences -contains $_.Xml.Include })
{
$hintPath = $Reference.GetMetadataValue("HintPath")

Write-Host "Matched againt $hintPath"

#If it is x64 specific add condition (Include 'Any Cpu' as x64)
if ($hintPath -match '.*\\(amd64|x64)\\.*\.dll$')
{
$Reference.Xml.Condition = "'TargetPlatform' != 'x86'"

$condition = $Reference.Xml.Condition
Write-Host "hintPath = $hintPath"
Write-Host "condition = $condition"

#Visual Studio doesnt allow the same reference twice (so try add friends)
$matchingReferences = $currentProject.GetItems('Reference') | ? {($_.Xml.Include -eq $Reference.Xml.Include) -and ($_.GetMetadataValue("HintPath") -match ".*\\(x86)\\.*\.dll$")}

#Add x86 Conditional
Write-Host "Adding reference to $x86"

$x86 = $hintPath -replace '(.*\\)(amd64|x64)(\\.*\.dll)$', '$1x86$3'
$x86Path = Join-Path $installPath $x86

$metaData = new-object "System.Collections.Generic.Dictionary``2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
$metaData.Add("HintPath", $x86)
$currentProject.AddItem('Reference', $Reference.Xml.Include, $metaData)

$newReference = $currentProject.GetItems('Reference') | ? {($_.Xml.Include -eq $Reference.Xml.Include) -and ($_.GetMetadataValue("HintPath") -eq $x86)} | Select-Object -First 1

$newReference.Xml.Condition = "'TargetPlatform' == 'x86'"
}

#If it is x86 specific add condition
if ($hintPath -match '.*\\x86\\.*\.dll$')
{
$Reference.Xml.Condition = "'TargetPlatform' == 'x86'"

$condition = $Reference.Xml.Condition
Write-Host "hintPath = $hintPath"
Write-Host "condition = $condition"

#Visual Studio doesnt allow the same reference twice (so try add friends)
$matchingReferences = $currentProject.GetItems('Reference') | ? {($_.Xml.Include -eq $Reference.Xml.Include) -and ($_.GetMetadataValue("HintPath") -match ".*\\(amd64|x64)\\.*\.dll$")}

#Add x64 Specific
$x64 = $hintPath -replace '(.*\\)(x86)(\\.*\.dll)$', '$1x64$3'
$x64Path = Join-Path $installPath $

Write-Host "Adding reference to $x64"

$metaData = new-object "System.Collections.Generic.Dictionary``2[[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[System.String, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]"
$metaData.Add("HintPath", $x64)
$currentProject.AddItem('Reference', $Reference.Xml.Include, $metaData)

$newReference = $currentProject.GetItems('Reference') | ? {($_.Xml.Include -eq $Reference.Xml.Include) -and ($_.GetMetadataValue("HintPath") -eq $x64)} | Select-Object -First 1

$newReference.Xml.Condition = "'TargetPlatform' != 'x86'"
}
}
}
18 changes: 18 additions & 0 deletions Meta.Vlc/tools/net45/Uninstall.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
param($installPath, $toolsPath, $package, $project)

$allowedReferences = @("Meta.Vlc, Version=16.5.1.0, Culture=neutral, processorArchitecture=x86")

# Full assembly name is required
Add-Type -AssemblyName 'Microsoft.Build, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

$projectCollection = [Microsoft.Build.Evaluation.ProjectCollection]::GlobalProjectCollection

$allProjects = $projectCollection.GetLoadedProjects($project.Object.Project.FullName).GetEnumerator();

if($allProjects.MoveNext())
{
foreach($Reference in $allProjects.Current.GetItems('Reference') | ? {$allowedReferences -contains $_.UnevaluatedInclude })
{
$allProjects.Current.RemoveItem($Reference)
}
}
5 changes: 4 additions & 1 deletion Nuget/Meta.Vlc.Wpf.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</dependencies>
</metadata>
<files>
<file src="..\x64\Release\.NET 3.5\zh-CHS\mscorlib.resources.dll" target="lib\net35\x64\zh-CHS\mscorlib.resources.dll" />
<!--<file src="..\x64\Release\.NET 3.5\zh-CHS\mscorlib.resources.dll" target="lib\net35\x64\zh-CHS\mscorlib.resources.dll" />-->
<file src="..\x64\Release\.NET 3.5\big5.nlp" target="lib\net35\x64\big5.nlp" />
<file src="..\x64\Release\.NET 3.5\bopomofo.nlp" target="lib\net35\x64\bopomofo.nlp" />
<file src="..\x64\Release\.NET 3.5\ksc.nlp" target="lib\net35\x64\ksc.nlp" />
Expand All @@ -55,5 +55,8 @@
<file src="..\x64\Release\.NET 4.5\Meta.Vlc.Wpf.XML" target="lib\net45\x64\Meta.Vlc.Wpf.XML" />
<file src="..\x86\Release\.NET 4.5\Meta.Vlc.Wpf.dll" target="lib\net45\x86\Meta.Vlc.Wpf.dll" />
<file src="..\x86\Release\.NET 4.5\Meta.Vlc.Wpf.XML" target="lib\net45\x86\Meta.Vlc.Wpf.XML" />

<file src="..\Meta.Vlc.Wpf\tools\net45\Install.ps1" target="tools\net45"/>
<file src="..\Meta.Vlc.Wpf\tools\net45\Uninstall.ps1" target="tools\net45"/>
</files>
</package>
9 changes: 6 additions & 3 deletions Nuget/Meta.Vlc.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<tags>vlc libvlc Meta media video</tags>
</metadata>
<files>
<file src="..\x64\Release\.NET 2.0\zh-CHS\mscorlib.resources.dll" target="lib\net20\x64\zh-CHS\mscorlib.resources.dll" />
<!--<file src="..\x64\Release\.NET 2.0\zh-CHS\mscorlib.resources.dll" target="lib\net20\x64\zh-CHS\mscorlib.resources.dll" />-->
<file src="..\x64\Release\.NET 2.0\big5.nlp" target="lib\net20\x64\big5.nlp" />
<file src="..\x64\Release\.NET 2.0\bopomofo.nlp" target="lib\net20\x64\bopomofo.nlp" />
<file src="..\x64\Release\.NET 2.0\ksc.nlp" target="lib\net20\x64\ksc.nlp" />
Expand All @@ -36,7 +36,7 @@
<file src="..\x64\Release\.NET 2.0\Meta.Vlc.XML" target="lib\net20\x64\Meta.Vlc.XML" />
<file src="..\x86\Release\.NET 2.0\Meta.Vlc.dll" target="lib\net20\x86\Meta.Vlc.dll" />
<file src="..\x86\Release\.NET 2.0\Meta.Vlc.XML" target="lib\net20\x86\Meta.Vlc.XML" />
<file src="..\x64\Release\.NET 3.0\zh-CHS\mscorlib.resources.dll" target="lib\net30\x64\zh-CHS\mscorlib.resources.dll" />
<!--<file src="..\x64\Release\.NET 3.0\zh-CHS\mscorlib.resources.dll" target="lib\net30\x64\zh-CHS\mscorlib.resources.dll" />-->
<file src="..\x64\Release\.NET 3.0\big5.nlp" target="lib\net30\x64\big5.nlp" />
<file src="..\x64\Release\.NET 3.0\bopomofo.nlp" target="lib\net30\x64\bopomofo.nlp" />
<file src="..\x64\Release\.NET 3.0\ksc.nlp" target="lib\net30\x64\ksc.nlp" />
Expand All @@ -55,7 +55,7 @@
<file src="..\x64\Release\.NET 3.0\Meta.Vlc.XML" target="lib\net30\x64\Meta.Vlc.XML" />
<file src="..\x86\Release\.NET 3.0\Meta.Vlc.dll" target="lib\net30\x86\Meta.Vlc.dll" />
<file src="..\x86\Release\.NET 3.0\Meta.Vlc.XML" target="lib\net30\x86\Meta.Vlc.XML" />
<file src="..\x64\Release\.NET 3.5\zh-CHS\mscorlib.resources.dll" target="lib\net35\x64\zh-CHS\mscorlib.resources.dll" />
<!--<file src="..\x64\Release\.NET 3.5\zh-CHS\mscorlib.resources.dll" target="lib\net35\x64\zh-CHS\mscorlib.resources.dll" />-->
<file src="..\x64\Release\.NET 3.5\big5.nlp" target="lib\net35\x64\big5.nlp" />
<file src="..\x64\Release\.NET 3.5\bopomofo.nlp" target="lib\net35\x64\bopomofo.nlp" />
<file src="..\x64\Release\.NET 3.5\ksc.nlp" target="lib\net35\x64\ksc.nlp" />
Expand All @@ -82,5 +82,8 @@
<file src="..\x64\Release\.NET 4.5\Meta.Vlc.XML" target="lib\net45\x64\Meta.Vlc.XML" />
<file src="..\x86\Release\.NET 4.5\Meta.Vlc.dll" target="lib\net45\x86\Meta.Vlc.dll" />
<file src="..\x86\Release\.NET 4.5\Meta.Vlc.XML" target="lib\net45\x86\Meta.Vlc.XML" />

<file src="..\Meta.Vlc\tools\net45\Install.ps1" target="tools\net45"/>
<file src="..\Meta.Vlc\tools\net45\Uninstall.ps1" target="tools\net45"/>
</files>
</package>
15 changes: 14 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,15 @@ Install [Meta.Vlc](https://www.nuget.org/packages/Meta.Vlc/)
```Powershell
PM> Install-Package Meta.Vlc
```
> For **net45** and above, full x86 and x64 support is available. Meta.Vlc will add
> conditional references to handled x86, x64, and AnyCpu.
Install [Meta.Vlc.Wpf](https://www.nuget.org/packages/Meta.Vlc.Wpf/)
```Powershell
PM> Install-Package Meta.Vlc.Wpf
```
> For **net45** and above, full x86 and x64 support is available. Meta.Vlc.Wpf will add
> conditional references to handled x86, x64, and AnyCpu.
Install [Meta.Vlc.Lib](https://www.nuget.org/packages/Meta.Vlc.Lib/)
```Powershell
Expand All @@ -28,10 +32,11 @@ PM> Install-Package Meta.Vlc.Lib
>LibVlc 的版本:
>2.2.0-Meta Weatherwax
>
>_Meta.Vlc.Lib include all files of LibVlc. You can use this dlls for Meta.Vlc and Meta.Vlc.Wpf._
>_Meta.Vlc.Lib includes all files of LibVlc. You can use these dlls for Meta.Vlc and Meta.Vlc.Wpf._
>_LibVlc Version:_
>_2.2.0-Meta Weatherwax_

## Api Documentation

See the api documentation of [Meta.Vlc](http://higan.me/Meta.Vlc/api/index.html).
Expand All @@ -49,6 +54,14 @@ See the api documentation of [Meta.Vlc](http://higan.me/Meta.Vlc/api/index.html)
>:x: :不兼容/Incompatible
>:interrobang: :部分功能可能不可用/Some functions may not be available
## Packaging NuGet
To generate package files there are a couple of important steps.

* In `Meta.Vlc\tools\net45\` and `Meta.Vlc.Wpf\tools\net45` for each script,
the `$allowedReferences` **must** have the `Version` match what the current dll's has set.
* Everything else is normal, build the package using `nuget pack Meta.Vlc.nuspec`,
`nuget pack Meta.Vlc.Wpf.nuspec` and `nuget pack Meta.Vlc.Lib.nuspec`

## Change Log

### 2016/07/08
Expand Down

0 comments on commit aecf57c

Please sign in to comment.