Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tasks/update build #227

Merged
merged 4 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
170 changes: 109 additions & 61 deletions Build/HccViewsetPackage.targets
Original file line number Diff line number Diff line change
@@ -1,62 +1,110 @@
<?xml version="1.0" encoding="windows-1252"?>
<!--
The MIT License (MIT)
Copyright (c) 2019 Upendo Ventures, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="MSBuild.Community.Tasks.Targets" />
<Target Name="PackageModule" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<XmlRead Prefix="n"
Namespace="http://schemas.microsoft.com/developer/msbuild/2003"
XPath="dotnetnuke/packages/package[1]/@version"
XmlFileName="$(DNNFileName).dnn">
<Output TaskParameter="Value" PropertyName="Version" />
</XmlRead>

<ItemGroup>
<InstallInclude Include="**\*.txt" Exclude="**\obj\**;**\_ReSharper*\**;packages\**;" />
</ItemGroup>

<CreateItem Include="$(LocalViewsetPath)\**\*.*">
<Output TaskParameter="Include" ItemName="Views" />
</CreateItem>

<Copy SourceFiles="@(Views)" DestinationFolder="$(MSBuildProjectDirectory)\Package\%(RecursiveDir)"/>

<!-- Deploy DLL's manually until Hotcakes has an installation manager -->
<!--Copy SourceFiles="@(BinInstallInclude)" DestinationFolder="$(MSBuildProjectDirectory)\Package"/-->

<CreateItem Include="$(MSBuildProjectDirectory)\Package\**\*.*">
<Output TaskParameter="Include" ItemName="OutputContent" />
</CreateItem>

<!-- Create the Install package -->
<Zip Files="@(OutputContent)" WorkingDirectory="$(MSBuildProjectDirectory)\Package" ZipFileName="$(PackageName)_$(Version)_Install.$(Extension)" />

<!-- Copy the Install package to the Packages folder -->
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(PackageName)_$(Version)_Install.$(Extension)" DestinationFolder="$(WebsiteInstallPath)" />

<!-- Cleanup -->
<Delete Files="$(MSBuildProjectDirectory)\$(PackageName)_$(Version)_Install.$(Extension)" />

<RemoveDir Directories ="$(MSBuildProjectDirectory)\Package" />

</Target>
<?xml version="1.0" encoding="windows-1252"?>
<!--
The MIT License (MIT)
Copyright (c) 2019 Upendo Ventures, LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this
software and associated documentation files (the "Software"), to deal in the Software
without restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to the following
conditions:

The above copyright notice and this permission notice shall be included in all copies
or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-->
<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="MSBuild.Community.Tasks.Targets" />
<Import Project="$(BuildScriptsPath)\Helpers.Targets" />
<Target Name="SetVersion" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<XmlRead Prefix="n"
Namespace="http://schemas.microsoft.com/developer/msbuild/2003"
XPath="dotnetnuke/packages/package[1]/@version"
XmlFileName="$(DNNFileName).dnn">
<Output TaskParameter="Value" PropertyName="Version" />
</XmlRead>

<ToShortVersion Version="$(Version)">
<Output PropertyName="sVersion" TaskParameter="ShortVersion" />
</ToShortVersion>

<!-- AssemblyInfo -->
<ReplaceFileText
Filename="$(MSBuildProjectDirectory)\Properties\AssemblyInfo.cs"
MatchExpression="AssemblyVersion\(&quot;[0-9|\\.]%2A&quot;\)"
ReplacementText="AssemblyVersion(&quot;$(Version)&quot;)" />
<ReplaceFileText
Filename="$(MSBuildProjectDirectory)\Properties\AssemblyInfo.cs"
MatchExpression="AssemblyFileVersion\(&quot;[0-9|\\.]%2A&quot;\)"
ReplacementText="AssemblyFileVersion(&quot;$(Version)&quot;)" />

<!-- Manifest -->
<ReplaceXmlAttributeValue
Filename="$(DNNFileName).dnn"
XPathAttributeSelector = "/dotnetnuke/packages/package/@version"
NewValue="$(Version)" />
<ReplaceXmlNodeText
Filename="$(DNNFileName).dnn"
XPathNodeSelector = "/dotnetnuke/packages/package[@name='$(PackageName)']/components/component[@type='Assembly']/assemblies/assembly/version[../name/text() = '$(AssemblyName).dll']"
NewValue="$(Version)" />
<ReplaceXmlNodeText
Filename="$(DNNFileName).dnn"
XPathNodeSelector = "/dotnetnuke/packages/package[@name='$(PackageName)']/components/component[@type='Script']/scripts/script[@type='UnInstall']/version"
NewValue="$(Version)" />

<!-- Symbols Manifest -->
<ReplaceXmlAttributeValue
Filename="$(DNNFileName)_Symbols.dnn"
XPathAttributeSelector = "/dotnetnuke/packages/package/@version"
NewValue="$(Version)" />
<ReplaceXmlAttributeValue
Filename="$(DNNFileName)_Symbols.dnn"
XPathAttributeSelector = "/dotnetnuke/packages/package/dependencies/dependency[@type='managedPackage'][text()='$(PackageName)']/@version"
NewValue="$(sVersion)" />

</Target>
<Target Name="PackageModule" Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<XmlRead Prefix="n"
Namespace="http://schemas.microsoft.com/developer/msbuild/2003"
XPath="dotnetnuke/packages/package[1]/@version"
XmlFileName="$(DNNFileName).dnn">
<Output TaskParameter="Value" PropertyName="Version" />
</XmlRead>

<ItemGroup>
<InstallInclude Include="**\*.txt" Exclude="**\obj\**;**\_ReSharper*\**;packages\**;" />
</ItemGroup>

<CreateItem Include="$(LocalViewsetPath)\**\*.*">
<Output TaskParameter="Include" ItemName="Views" />
</CreateItem>

<Copy SourceFiles="@(Views)" DestinationFolder="$(MSBuildProjectDirectory)\Package\%(RecursiveDir)"/>

<!-- Deploy DLL's manually until Hotcakes has an installation manager -->
<!--Copy SourceFiles="@(BinInstallInclude)" DestinationFolder="$(MSBuildProjectDirectory)\Package"/-->

<CreateItem Include="$(MSBuildProjectDirectory)\Package\**\*.*">
<Output TaskParameter="Include" ItemName="OutputContent" />
</CreateItem>

<!-- Create the Install package -->
<Zip Files="@(OutputContent)" WorkingDirectory="$(MSBuildProjectDirectory)\Package" ZipFileName="$(PackageName)_$(Version)_Install.$(Extension)" />

<!-- Copy the Install package to the Packages folder -->
<Copy SourceFiles="$(MSBuildProjectDirectory)\$(PackageName)_$(Version)_Install.$(Extension)" DestinationFolder="$(WebsiteInstallPath)" />

<!-- Cleanup -->
<Delete Files="$(MSBuildProjectDirectory)\$(PackageName)_$(Version)_Install.$(Extension)" />

<RemoveDir Directories ="$(MSBuildProjectDirectory)\Package" />

</Target>
</Project>
129 changes: 129 additions & 0 deletions Build/Helpers.targets
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="ReplaceFileText" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Filename ParameterType="System.String" Required="true" />
<MatchExpression ParameterType="System.String" Required="true" />
<ReplacementText ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Using Namespace="System.IO" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
File.WriteAllText(
Filename,
Regex.Replace(File.ReadAllText(Filename), MatchExpression, ReplacementText)
);
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="ReplaceXmlNodeText" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Filename ParameterType="System.String" Required="true" />
<XPathNodeSelector ParameterType="System.String" Required="true" />
<NewValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Using Namespace="System" />
<Using Namespace="System.Xml" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var xdoc = new XmlDocument();
xdoc.Load(Filename);
var nodes = xdoc.SelectNodes(XPathNodeSelector);
if(nodes != null)
{
foreach (XmlNode node in nodes)
{
node.InnerText = NewValue;
}
}
xdoc.Save(Filename);
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="AppendXmlNodeText" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Filename ParameterType="System.String" Required="true" />
<XPathNodeSelector ParameterType="System.String" Required="true" />
<NewValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Using Namespace="System" />
<Using Namespace="System.Xml" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var xdoc = new XmlDocument();
xdoc.Load(Filename);
var nodes = xdoc.SelectNodes(XPathNodeSelector);
if(nodes != null)
{
foreach (XmlNode node in nodes)
{
node.InnerText = node.InnerText + NewValue;
}
}
xdoc.Save(Filename);
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="ReplaceXmlAttributeValue" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Filename ParameterType="System.String" Required="true" />
<XPathAttributeSelector ParameterType="System.String" Required="true" />
<NewValue ParameterType="System.String" Required="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Reference Include="System.Xml" />
<Using Namespace="System" />
<Using Namespace="System.Xml" />
<Code Type="Fragment" Language="cs">
<![CDATA[
var xdoc = new XmlDocument();
xdoc.Load(Filename);
var attributes = xdoc.SelectNodes(XPathAttributeSelector);
if (attributes != null)
{
foreach (XmlAttribute attribute in attributes)
{
attribute.Value = NewValue;
}
}
xdoc.Save(Filename);
]]>
</Code>
</Task>
</UsingTask>
<UsingTask TaskName="ToShortVersion" TaskFactory="CodeTaskFactory" AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Version ParameterType="System.String" Required="true" />
<ShortVersion ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Core" />
<Using Namespace="System" />
<Code Type="Fragment" Language="cs">
<![CDATA[
ShortVersion = "";
foreach (var s in Version.Split('.'))
{
if(!string.IsNullOrEmpty(ShortVersion)) ShortVersion += ".";
ShortVersion += s.TrimStart('0');
if(ShortVersion.EndsWith(".")) ShortVersion += "0";
}
]]>
</Code>
</Task>
</UsingTask>

</Project>
Loading