Skip to content

Instantly share code, notes, and snippets.

@LucGosso
Created June 5, 2019 13:36
Show Gist options
  • Save LucGosso/557436f6b8e828839ae7976814054a21 to your computer and use it in GitHub Desktop.
Save LucGosso/557436f6b8e828839ae7976814054a21 to your computer and use it in GitHub Desktop.
Use build tasks and nuspec to build Episerver addon in visual studio ( https://devblog.gosso.se/?p=1148 )
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<UsingTask TaskName="ZipDirectory" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<InputPath ParameterType="System.String" Required="true" />
<OutputFileName ParameterType="System.String" Required="true" />
<OverwriteExistingFile ParameterType="System.Boolean" Required="false" />
</ParameterGroup>
<Task>
<Reference Include=" System.IO.Compression.FileSystem" />
<Using Namespace="System.IO" />
<Using Namespace="System.IO.Compression" />
<Code Type="Fragment" Language="cs">
<![CDATA[
if(this.OverwriteExistingFile) {
File.Delete(this.OutputFileName);
}
ZipFile.CreateFromDirectory(this.InputPath, this.OutputFileName);
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="GetVersion"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<AssemblyPath ParameterType="System.String" Required="true" />
<Version ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Using Namespace="System" />
<Using Namespace="System.Diagnostics" />
<Code Type="Fragment" Language="cs">
<![CDATA[
Log.LogMessage("Getting version details of assembly at: " + this.AssemblyPath, MessageImportance.High);
this.Version = FileVersionInfo.GetVersionInfo(this.AssemblyPath).FileVersion;
]]>
</Code>
</Task>
</UsingTask>
<PropertyGroup>
<SolutionDir Condition="$(SolutionDir) == ''">$(MSBuildProjectDirectory)\..\</SolutionDir>
<NuGetExe>$(SolutionDir)FotoWare.PlugIns.Episerver\.nuget\NuGet.exe</NuGetExe>
<TmpOutDir>$(SolutionDir)FotoWare.PlugIns.Episerver\tmp</TmpOutDir>
<NuspecFile>$(SolutionDir)FotoWare.PlugIns.Episerver\FotoWare.PlugIns.Episerver.nuspec</NuspecFile>
</PropertyGroup>
<Target Name="CreateNugetPackage" AfterTargets="Build">
<PropertyGroup>
<Version></Version>
</PropertyGroup>
<GetVersion AssemblyPath="$(SolutionDir)FotoWare.PlugIns.Episerver\bin\$(Configuration)\FotoWare.PlugIns.Episerver.dll">
<Output TaskParameter="Version" PropertyName="Version" />
</GetVersion>
<!-- Update the module config with the version information -->
<XmlPoke XmlInputPath="$(SolutionDir)Alloytemplates\modules\_protected\FotoWare.PlugIns.Episerver\module.config" Query="/module/@clientResourceRelativePath" Value="$(Version)" />
<!-- Create the Versioned out dir for the client resources $(Version)-->
<MakeDir Directories="$(TmpOutDir)\content\modules\_protected\" />
<!-- Copy -->
<ItemGroup>
<ClientResources Include="$(SolutionDir)Alloytemplates\modules\_protected\FotoWare.PlugIns.Episerver\**\*" />
</ItemGroup>
<Copy SourceFiles="$(SolutionDir)FotoWare.PlugIns.Episerver\MSBuild\web.config.install.xdt" DestinationFolder="$(TmpOutDir)\content" />
<Copy SourceFiles="$(SolutionDir)FotoWare.PlugIns.Episerver\MSBuild\web.config.uninstall.xdt" DestinationFolder="$(TmpOutDir)\content" />
<!--<Copy SourceFiles="$(SolutionDir)\module.config" DestinationFolder="$(TmpOutDir)\content" />-->
<Copy SourceFiles="@(ClientResources)" DestinationFiles="@(ClientResources -> '$(TmpOutDir)\content\modules\_protected\FotoWare.PlugIns.Episerver\%(RecursiveDir)%(Filename)%(Extension)')"/>
<!--Create the Zip file-->
<ZipDirectory
InputPath="$(SolutionDir)Alloytemplates\modules\_protected\FotoWare.PlugIns.Episerver\"
OutputFileName="$(TmpOutDir)\content\modules\_protected\FotoWare.PlugIns.Episerver\FotoWare.PlugIns.Episerver.zip"
OverwriteExistingFile="true" />
<RemoveDir Directories="$(TmpOutDir)\content\modules\_protected\FotoWare.PlugIns.Episerver\$(Version)" />
<!-- Create the package -->
<PropertyGroup>
<NugetCommand>
"$(NuGetExe)" pack "$(NuspecFile)" -OutputDirectory "$(OutDir.TrimEnd('\\'))" -Version "$(Version)" -Properties Configuration=$(Configuration)
</NugetCommand>
</PropertyGroup>
<Exec Command="$(NugetCommand)"/>
<!-- Cleanup -->
<RemoveDir Directories="$(TmpOutDir)" />
</Target>
</Project>
<?xml version="1.0"?>
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<metadata>
<id>FotoWare.PlugIns.Episerver</id>
<version>$version$</version>
<title>Episerver Addon integrates Fotoware DAM with Episerver CMS and Commerce</title>
<authors>FotoWare</authors>
<owners>FotoWare</owners>
<iconUrl>https://www.fotoware.com/hubfs/FotoWare_January2018/image/favicon.ico</iconUrl>
<projectUrl>https://learn.fotoware.com/02_FotoWeb_8.0/Integrating_FotoWeb_with_third-party_systems/Episerver_plugin_documentation</projectUrl>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>This Episerver Addon integrates Fotoware DAM with Episerver CMS and Commerce</description>
<releaseNotes>More information check FotoWare website </releaseNotes>
<copyright>MIT</copyright>
<tags>EPiServerModulePackage EPiServer-UI EPiServerAddOn ThirdPartyAddon FotoWare FotoWare Imagebank Mediabank Integration CMS11 Epinova TinyMCE</tags>
<dependencies>
<dependency id="EPiServer.CMS.UI" version="[11.15,12.0)" />
<dependency id="EPiServer.CMS.TinyMce" version="[2.0,3.0)" />
<dependency id="System.Json" version="[4.5,6.0)" />
</dependencies>
</metadata>
<files>
<file src="bin\$configuration$\FotoWare.PlugIns.Episerver.dll" target="lib\net45\" />
<file src="tmp\content\**\*" target="content" />
<file src="..\AlloyTemplates\Views\Shared\DisplayTemplates\FotoWareImageUrl.cshtml" target="content\views\shared\displaytemplates\" />
<file src="..\AlloyTemplates\Views\Shared\DisplayTemplates\FotoWareImage.cshtml" target="content\views\shared\displaytemplates\" />
<file src="msbuild\readme.txt" target="" />
<file src="..\AlloyTemplates\fotoware\*" target="tools\extras" />
<file src="..\FotoWare.PlugIns.Episerver.ArchiveImport\fotowareImport*" target="tools\extras" />
</files>
</package>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment