From 8492a49538efe7f4036ea0934d3f4cb683df0a37 Mon Sep 17 00:00:00 2001
From: chefkoch <chefkoch@team-mediaportal.com>
Date: Wed, 10 Jul 2013 01:44:24 +0200
Subject: [PATCH 2/2] moved pre- and postbuild into MSBuild *.targets

---
 Build/Build_OV_MP2.bat                             |  2 +
 .../NuGetPackage/OnlineVideos.MediaPortal2.nuspec  | 18 ++++++++
 .../OnlineVideos.MediaPortal2.csproj               | 19 ++------
 OnlineVideos.MediaPortal2/build.targets            | 53 ++++++++++++++++++++++
 OnlineVideos/OnlineVideos.csproj                   | 21 ++++-----
 OnlineVideos/build.targets                         |  8 ++++
 6 files changed, 96 insertions(+), 25 deletions(-)
 create mode 100644 Build/Build_OV_MP2.bat
 create mode 100644 OnlineVideos.MediaPortal2/NuGetPackage/OnlineVideos.MediaPortal2.nuspec
 create mode 100644 OnlineVideos.MediaPortal2/build.targets
 create mode 100644 OnlineVideos/build.targets

diff --git a/Build/Build_OV_MP2.bat b/Build/Build_OV_MP2.bat
new file mode 100644
index 0000000..f5e9912
--- /dev/null
+++ b/Build/Build_OV_MP2.bat
@@ -0,0 +1,2 @@
+
+@"%WINDIR%\Microsoft.NET\Framework\v4.0.30319\MSBUILD.exe" ..\OnlineVideos.MediaPortal2.sln /target:Rebuild /property:Configuration=Release
diff --git a/OnlineVideos.MediaPortal2/NuGetPackage/OnlineVideos.MediaPortal2.nuspec b/OnlineVideos.MediaPortal2/NuGetPackage/OnlineVideos.MediaPortal2.nuspec
new file mode 100644
index 0000000..88d0616
--- /dev/null
+++ b/OnlineVideos.MediaPortal2/NuGetPackage/OnlineVideos.MediaPortal2.nuspec
@@ -0,0 +1,18 @@
+﻿<?xml version="1.0" encoding="utf-8"?>
+<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
+    <metadata>
+        <id>OnlineVideos.MediaPortal2</id>
+        <version>$version$</version>
+        <title>OnlineVideos.MediaPortal2</title>
+        <authors>offbyone</authors>
+        <owners>offbyone</owners>
+        <licenseUrl>https://code.google.com/p/mp-onlinevideos2/</licenseUrl>
+        <projectUrl>https://code.google.com/p/mp-onlinevideos2/</projectUrl>
+        <requireLicenseAcceptance>false</requireLicenseAcceptance>
+        <description>OnlineVideos is a plug-in for the open-source media center application MediaPortal running on the Windows platform. The main goal of this plug-in is the seamless integration of video content provided by various websites with the main application. In order to achieve this, playback is heavily dependent on directshow filters installed on the users operating system. The discovery or scraping of playback links is very flexible and can be done by reading rss feeds, parsing html with regular expressions or even programming against APIs provided by websites. The plug-in interface will unify the user experience from all the different websites into one simple structure. Every site will span a hierarchical tree of categories, each showing a set of videos with descriptions and thumbnails. Support for searching, filtering, bookmarking favorites and downloading is included as well.</description>
+        <summary>MediaPortal OnlineVideos Plugin</summary>
+    </metadata>
+    <files>
+        <file src="PluginContent\**\*.*" target="PluginContent" exclude="**\.svn\**" />
+    </files>
+</package>
\ No newline at end of file
diff --git a/OnlineVideos.MediaPortal2/OnlineVideos.MediaPortal2.csproj b/OnlineVideos.MediaPortal2/OnlineVideos.MediaPortal2.csproj
index b8c0ac1..f884fe2 100644
--- a/OnlineVideos.MediaPortal2/OnlineVideos.MediaPortal2.csproj
+++ b/OnlineVideos.MediaPortal2/OnlineVideos.MediaPortal2.csproj
@@ -174,21 +174,12 @@
     <Content Include="Skin\Titanium\screens\details.xaml" />
   </ItemGroup>
   <ItemGroup>
+    <None Include="NuGetPackage\OnlineVideos.MediaPortal2.nuspec" />
     <None Include="Properties\VersionInfo.cs.tmpl" />
   </ItemGroup>
+  <ItemGroup>
+    <None Include="build.targets" />
+  </ItemGroup>
   <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <PropertyGroup>
-    <PostBuildEvent>mkdir "$(SolutionDir)..\MediaPortal-2\MediaPortal\Bin\MP2-Client\bin\x86\Debug\Plugins\OnlineVideos\Language"
-robocopy "$(ProjectDir)Language" "$(SolutionDir)..\MediaPortal-2\MediaPortal\Bin\MP2-Client\bin\x86\Debug\Plugins\OnlineVideos\Language" /MIR /NP /XD .svn
-mkdir "$(SolutionDir)..\MediaPortal-2\MediaPortal\Bin\MP2-Client\bin\x86\Debug\Plugins\OnlineVideos\Skin"
-robocopy "$(ProjectDir)Skin" "$(SolutionDir)..\MediaPortal-2\MediaPortal\Bin\MP2-Client\bin\x86\Debug\Plugins\OnlineVideos\Skin" /MIR /NP /XD .svn
-xcopy /Y "$(TargetDir)$(ProjectName).*" "$(SolutionDir)..\MediaPortal-2\MediaPortal\Bin\MP2-Client\bin\x86\Debug\Plugins\OnlineVideos\"
-xcopy /Y "$(TargetDir)OnlineVideos.*" "$(SolutionDir)..\MediaPortal-2\MediaPortal\Bin\MP2-Client\bin\x86\Debug\Plugins\OnlineVideos\"
-xcopy /Y "$(ProjectDir)plugin.xml" "$(SolutionDir)..\MediaPortal-2\MediaPortal\Bin\MP2-Client\bin\x86\Debug\Plugins\OnlineVideos"
-mkdir "$(SolutionDir)..\MediaPortal-2\MediaPortal\Bin\MP2-Client\bin\x86\Debug\Plugins\OnlineVideos\MPUrlSourceSplitter"
-xcopy /Y "$(SolutionDir)MPUrlSourceSplitter\bin_Win32\*.*" "$(SolutionDir)..\MediaPortal-2\MediaPortal\Bin\MP2-Client\bin\x86\Debug\Plugins\OnlineVideos\MPUrlSourceSplitter"</PostBuildEvent>
-  </PropertyGroup>
-  <PropertyGroup>
-    <PreBuildEvent>subwcrev "$(SolutionDir)." "$(ProjectDir)Properties\VersionInfo.cs.tmpl" "$(ProjectDir)Properties\VersionInfo.cs"</PreBuildEvent>
-  </PropertyGroup>
+  <Import Project="build.targets" />
 </Project>
\ No newline at end of file
diff --git a/OnlineVideos.MediaPortal2/build.targets b/OnlineVideos.MediaPortal2/build.targets
new file mode 100644
index 0000000..e465ebf
--- /dev/null
+++ b/OnlineVideos.MediaPortal2/build.targets
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+
+  <Target Name="BeforeBuild">
+    <Exec Command='subwcrev "$(SolutionDir)." "$(ProjectDir)Properties\VersionInfo.cs.tmpl" "$(ProjectDir)Properties\VersionInfo.cs"'/>
+  </Target>
+
+  <PropertyGroup>
+    <PluginDestination>$(SolutionDir)..\MediaPortal-2\MediaPortal\Bin\MP2-Client\bin\x86\Debug\Plugins\OnlineVideos\</PluginDestination>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PluginFiles Include="$(TargetDir)$(ProjectName).*" />
+    <PluginFiles Include="$(TargetDir)OnlineVideos.*" />
+    <PluginFiles Include="$(ProjectDir)plugin.xml" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <LanguageFiles Include="$(ProjectDir)Language\*.*" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <SkinFiles Include="$(ProjectDir)Skin\**\*.*" Exclude="$(ProjectDir)Skin\**\.svn\**" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <MPUrlSourceSplitterFiles Include="$(SolutionDir)MPUrlSourceSplitter\bin_Win32\*.*" />
+  </ItemGroup>
+
+  <Target Name="AfterBuild">
+    <Copy SourceFiles="@(PluginFiles)" DestinationFolder="$(PluginDestination)" />
+    <Copy SourceFiles="@(LanguageFiles)" DestinationFolder="$(PluginDestination)Language\" />
+    <Copy SourceFiles="@(SkinFiles)"
+          DestinationFiles="@(SkinFiles->'$(PluginDestination)Skin\%(RecursiveDir)%(Filename)%(Extension)')" />
+    <Copy SourceFiles="@(MPUrlSourceSplitterFiles)" DestinationFolder="$(PluginDestination)MPUrlSourceSplitter\" />
+
+    <!-- Copy again to NuGetPackage folder for simple package creation -->
+    <PropertyGroup>
+      <PackageContent>$(ProjectDir)NuGetPackage\PluginContent\</PackageContent>
+    </PropertyGroup>
+    <Copy SourceFiles="@(PluginFiles)" DestinationFolder="$(PackageContent)" />
+    <Copy SourceFiles="@(LanguageFiles)" DestinationFolder="$(PackageContent)Language\" />
+    <Copy SourceFiles="@(SkinFiles)"
+          DestinationFiles="@(SkinFiles->'$(PackageContent)Skin\%(RecursiveDir)%(Filename)%(Extension)')" />
+    <Copy SourceFiles="@(MPUrlSourceSplitterFiles)" DestinationFolder="$(PackageContent)MPUrlSourceSplitter\" />
+
+    <!-- Uncomment to enable automatic packaging -->
+    <!--
+    It might be worth also to change the BeforeBuild subversion revision detection to make it a MSBuild property and reuse it here.
+    <Exec WorkingDirectory="$(ProjectDir)NuGetPackage" Command="$(NuGetExePath) pack OnlineVideos.MediaPortal2.nuspec -Version 2.1.0" />
+    -->
+  </Target>
+</Project>
\ No newline at end of file
diff --git a/OnlineVideos/OnlineVideos.csproj b/OnlineVideos/OnlineVideos.csproj
index f69a2e2..2b93653 100644
--- a/OnlineVideos/OnlineVideos.csproj
+++ b/OnlineVideos/OnlineVideos.csproj
@@ -46,7 +46,7 @@
     <DebugSymbols>true</DebugSymbols>
     <DebugType>Full</DebugType>
     <Optimize>false</Optimize>
-    <OutputPath>$(ProgramFiles)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\</OutputPath>
+    <OutputPath>bin\Debug</OutputPath>
     <DefineConstants>TRACE;DEBUG;NET35</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
@@ -56,7 +56,7 @@
   <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
     <DebugType>none</DebugType>
     <Optimize>true</Optimize>
-    <OutputPath>$(ProgramFiles)\Team MediaPortal\MediaPortal\plugins\Windows\OnlineVideos\</OutputPath>
+    <OutputPath>bin\Release</OutputPath>
     <DefineConstants>TRACE;NET35</DefineConstants>
     <ErrorReport>prompt</ErrorReport>
     <WarningLevel>4</WarningLevel>
@@ -1117,7 +1117,6 @@
     <Compile Include="WebCache.cs" />
   </ItemGroup>
   <ItemGroup>
-    <None Include="Properties\VersionInfo.cs.tmpl" />
     <None Include="Web References\OnlineVideosWebservice\OnlineVideos.wsdl" />
     <EmbeddedResource Include="RssToolkit\Resources\Rss20.xsd" />
   </ItemGroup>
@@ -1183,12 +1182,12 @@
       <Install>true</Install>
     </BootstrapperPackage>
   </ItemGroup>
-  <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
-  <PropertyGroup>
-    <PostBuildEvent>
-    </PostBuildEvent>
-  </PropertyGroup>
-  <PropertyGroup>
-    <PreBuildEvent>subwcrev "$(SolutionDir)." "$(ProjectDir)Properties\VersionInfo.cs.tmpl" "$(ProjectDir)Properties\VersionInfo.cs"</PreBuildEvent>
-  </PropertyGroup>
+  <ItemGroup>
+    <None Include="Properties\VersionInfo.cs.tmpl" />
+  </ItemGroup>
+  <ItemGroup>
+    <None Include="build.targets" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <Import Project="build.targets" />
 </Project>
\ No newline at end of file
diff --git a/OnlineVideos/build.targets b/OnlineVideos/build.targets
new file mode 100644
index 0000000..07f168d
--- /dev/null
+++ b/OnlineVideos/build.targets
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
+
+  <Target Name="BeforeBuild">
+    <Exec Command='subwcrev "$(SolutionDir)." "$(ProjectDir)Properties\VersionInfo.cs.tmpl" "$(ProjectDir)Properties\VersionInfo.cs"'/>
+  </Target>
+
+</Project>
\ No newline at end of file
-- 
1.8.1.msysgit.1

