diff --git a/Meta.Vlc.Wpf/tools/net45/Install.ps1 b/Meta.Vlc.Wpf/tools/net45/Install.ps1 new file mode 100644 index 0000000..e08b058 --- /dev/null +++ b/Meta.Vlc.Wpf/tools/net45/Install.ps1 @@ -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'" + } + } +} \ No newline at end of file diff --git a/Meta.Vlc.Wpf/tools/net45/Uninstall.ps1 b/Meta.Vlc.Wpf/tools/net45/Uninstall.ps1 new file mode 100644 index 0000000..d3676fb --- /dev/null +++ b/Meta.Vlc.Wpf/tools/net45/Uninstall.ps1 @@ -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) + } +} \ No newline at end of file diff --git a/Meta.Vlc.sln b/Meta.Vlc.sln index 76a490c..12d120b 100644 --- a/Meta.Vlc.sln +++ b/Meta.Vlc.sln @@ -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 @@ -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 diff --git a/Meta.Vlc/tools/net45/Install.ps1 b/Meta.Vlc/tools/net45/Install.ps1 new file mode 100644 index 0000000..5964f01 --- /dev/null +++ b/Meta.Vlc/tools/net45/Install.ps1 @@ -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'" + } + } +} \ No newline at end of file diff --git a/Meta.Vlc/tools/net45/Uninstall.ps1 b/Meta.Vlc/tools/net45/Uninstall.ps1 new file mode 100644 index 0000000..f0f8fe8 --- /dev/null +++ b/Meta.Vlc/tools/net45/Uninstall.ps1 @@ -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) + } +} \ No newline at end of file diff --git a/Nuget/Meta.Vlc.Wpf.nuspec b/Nuget/Meta.Vlc.Wpf.nuspec index 50d6819..c78f345 100644 --- a/Nuget/Meta.Vlc.Wpf.nuspec +++ b/Nuget/Meta.Vlc.Wpf.nuspec @@ -28,7 +28,7 @@ - + @@ -55,5 +55,8 @@ + + + \ No newline at end of file diff --git a/Nuget/Meta.Vlc.nuspec b/Nuget/Meta.Vlc.nuspec index f4e8fbb..eb66b16 100644 --- a/Nuget/Meta.Vlc.nuspec +++ b/Nuget/Meta.Vlc.nuspec @@ -17,7 +17,7 @@ vlc libvlc Meta media video - + @@ -36,7 +36,7 @@ - + @@ -55,7 +55,7 @@ - + @@ -82,5 +82,8 @@ + + + \ No newline at end of file diff --git a/README.md b/README.md index 0cdcbc0..8a21ec5 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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). @@ -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