In the following phing xml, inside the "skel" target I check if the app is configured, if it's not then I call the configure target and then apply the config to several files.
The problem is that property db.host is not set after the phingcall, even though it is set after the propertyprompt.
What am I missing?
<!-- base configuration -->
<property name="paths.config" value="config" />
<property name="paths.config.file" value="${paths.config}/environment.ini" />
<available file="${paths.config.file}" property="configured" />
<target name="configure">
<if>
<equals arg1="${configured}" arg2="true" />
<then>
<echo message="Reconfigure ..." />
</then>
<else>
<echo message="Configure ..." />
</else>
</if>
<propertyprompt propertyName="db.host" defaultValue="localhost" promptText="Mysql Server Host" />
</target>
<target name="skel">
<echo msg="Skel files..." />
<if>
<equals arg1="${configured}" arg2="${configured}" />
<then>
<echo message="Missing config file ..." />
<phingcall target="configure" />
</then>
</if>
<echo message="${db.host}" />
<copy todir="config">
<mapper type="glob" from="*.skel" to="*"/>
<filterchain>
<expandproperties />
</filterchain>
<fileset dir="config">
<include name="*.skel" />
</fileset>
</copy>
</target>
I think the phingcall will create a new environment internally. When the configure target is done, this environment is out of scope.
This means it is not possible to use a separate configure target as you are suggesting.
The only solution might be to make the configure target create a configuration file which is used by the other targets.
Properties set inside of targets are scoped to those targets and are not accessible outside their parent targets.
From the documentation for PropertyTask:
Important note about scope: when the <property> tag is called inside a <phingcall> tag, any properties are set in a new local scope. Thus, any properties or other variables set inside that scope will cease to exist (or revert to their previous value) once the parent <phingcall> tag completes.
Related
We're using Cruise Control v1.8.5. We have next scenario:
checkout source code from git repository
run some scripts to build project (e.g. npm install && cordova clean, cordova build, also minify some css files, compile typescript ...)
Now we want to add label on successfull build. Therefore I found that cruisecontrol has labeller option, so I added:
<cb:define name="Mylabeller">
<labeller type="defaultlabeller">
<initialBuildLabel>1</initialBuildLabel>
<labelFormat>0</labelFormat>
<incrementOnFailure>true</incrementOnFailure>
<labelPrefixFile>X:\BuildFiles\myProject\version.txt</labelPrefixFile>
<labelPrefixFileSearchPattern>\d\.\d\.\d\.</labelPrefixFileSearchPattern>
</labeller>
</cb:define>
But the problem is that, this is done before source code is retrieved (git) from repository. I read version from my project and then CruiseControl with regex reads version and outputs something like: 1.0.3.buildNumber.
How to set/update label prefix version after retrieving source code from repository. It reads old one, before checkout. I also read about dynamic variables, can they be somehow set or something?
Appending project's xml:
<cb:scope ProjDirName="myProject">
<project name="myProject" queue="Daily" queuePriority="30">
<workingDirectory>D:\BuildFiles\$(ProjDirName)\Working</workingDirectory>
<artifactDirectory>D:\BuildFiles\$(ProjDirName)\Artifacts</artifactDirectory>
<cb:sourcecontrol module="Modul1" TagOnSuccess="false" Branch="$(BranchDevelop)" />
<tasks>
<cb:NpmInstall />
<cb:Build />
</tasks>
<cb:Mylabeller />
<cb:commonall />
</project>
</cb:scope>
Figured that CruiseControl sets next build version when project build is started and before project's xml is read (checkout, tasks, ...).
CruiseControl project build log:
<parameters>
<parameter name="$CCNetArtifactDirectory" value="D:\BuildFiles\MyProject\Artifacts" />
<parameter name="$CCNetBuildCondition" value="ForceBuild" />
<parameter name="$CCNetBuildDate" value="2016-01-25" />
<parameter name="$CCNetBuildId" value="9d8234720e7342a3aa636aacc120eb13" />
<parameter name="$CCNetBuildTime" value="13:49:42" />
<parameter name="$CCNetFailureTasks" value="System.Collections.ArrayList" />
<parameter name="$CCNetFailureUsers" value="System.Collections.ArrayList" />
<parameter name="$CCNetIntegrationStatus" value="Unknown" />
<parameter name="$CCNetLabel" value="1.0.88" />
<parameter name="$CCNetLastIntegrationStatus" value="Failure" />
<parameter name="$CCNetListenerFile" value="D:\BuildFiles\MyProject\Artifacts\MyProject_ListenFile.xml" />
<parameter name="$CCNetModifyingUsers" value="System.Collections.ArrayList" />
<parameter name="$CCNetNumericLabel" value="88" />
<parameter name="$CCNetProject" value="MyProject" />
<parameter name="$CCNetProjectUrl" value="http://BUILDer/ccnet" />
<parameter name="$CCNetRequestSource" value="machineName1" />
<parameter name="$CCNetUser" value="user1" />
<parameter name="$CCNetWorkingDirectory" value="D:\BuildFiles\MyProject\Working" />
<parameter name="$LastChangeNumber" value="96ece86d55f83c8eb129cbfeb01724a3d37bb18a" />
Also I makes sense that Continuous Integration dictates application version e.g. major.minor.build instead that each commit dictates version.
Solution:
<cb:scope ProjDirName="myProject">
<project name="myProject" queue="Daily" queuePriority="30">
<workingDirectory>D:\BuildFiles\$(ProjDirName)\Working</workingDirectory>
<artifactDirectory>D:\BuildFiles\$(ProjDirName)\Artifacts</artifactDirectory>
<cb:sourceControlMyProject Branch="develop"/>
<cb:dailytrigger />
<tasks>
<cb:NpmInstall />
<cb:BuildRelease />
<cb:PublishAfter />
</tasks>
<publishers>
<cb:commonpublish/>
</publishers>
<cb:MyLabeller LabelPrefix="1.0." /> <!-- version is fixed -->
<cb:commonall />
</project>
</cb:scope>
And labeller:
<cb:define name="MyLabeller">
<labeller type="defaultlabeller">
<initialBuildLabel>1</initialBuildLabel>
<prefix>$(LabelPrefix)</prefix>
<incrementOnFailure>true</incrementOnFailure>
<labelFormat>0</labelFormat>
</labeller>
</cb:define>
Currently this setup is ok. In case we'll be developing version 1.1 upper setup must be changed. Main point was to get versioning working e.g. 1.0. + cruiseControl_next_build_number.
I am trying to hide the console when running the Haxe application.
I am using FlashDevelop to compile Haxe into hxcpp, and this is my project.xml
<?xml version="1.0" encoding="utf-8"?>
<project>
<!-- metadata, make sure 'package' is at least 3 segments (ie. com.mycompany.myproject) -->
<meta title="haxeGame" package="haxeGame" version="1.0.0" company="xiggie" />
<!-- output -->
<app main="Main" file="haxeGame" path="bin" />
<window width="800" height="480" fps="60" background="0x000000" orientation="landscape" resizable="false" borderless="true" />
<window vsync="true" antialiasing="6" />
<!-- classpath, haxe libs -->
<classpath name="src" />
<haxelib name="openfl" />
<haxelib name="actuate" />
<!-- assets -->
<icon path="assets/texture.jpg" />
<assets path="assets" rename="assets" />
<!-- optimize output
<haxeflag name="-dce full" /> -->
<!-- Windows app: hide console -->
<setenv name="no_console" value="1" />
<flag value="subsystem:windows" />
</project>
I have tried all of these:
<haxeflag name="-D no_console" />
<haxedef name="no_console" />
<setenv name="no_console" value="1" />
Is it actually possible to remove the console from the release app?
The console should be hidden by default. To make it appear one needs to add
<setenv name="SHOW_CONSOLE" />
However, when using mingw instead of msvc as compiler, the toolchain configuration that comes with hxcpp currently does not pass the flag to the linker that avoids the creation of a console window.
To work around this, search for the mingw-toolchain.xml in your haxe installation and add the -mwindows flag to the linker configuration.
I created a pull request for this https://github.com/HaxeFoundation/hxcpp/pull/286
I want to copy files over to a server but before i do this i would like to include the latest msi file that i generate.
I noticed that the ItemGroup and Item have a Condition attribute but i do not know how to utilize this to include the latest file.
So far this is my setup:
<Target Name="AfterBuild">
<ItemGroup>
<Installers Include="\\SERVERNAME\BuildOutput\ProductStream\**\Installers\Customer\Installer.msi"/>
</ItemGroup>
<Message Text="FirstItem: %(Installers.Filename)" />
<Message Text="FirstItem: %(Installers.FullPath)" />
The output of this are two files:
e.g
\\Servername\BuildOutput\ProductStream\Installers\ProductStreamV2.1.1202.1402\Installer.msi
\\Servername\BuildOutput\ProductStream\Installers\ProductStreamV2.1.1405.1301\Installer.msi
I want to include the 2.1.1405.1301 build in the Item as this is the latest one.
I would appreciate if someone would assist me because i cannot find how to go about doing this from the MSDN blogs.
Thanks,
You could use a custom task for this purpose. It allows you to filter items any way you want. Here I used regular expressions to select the latest installer:
<Target Name="AfterBuild">
<ItemGroup>
<Installers Include="**\Installer.msi"/>
</ItemGroup>
<SelectLatestInstaller Installers="#(Installers)">
<Output TaskParameter="LatestInstaller" ItemName="LatestInstaller" />
</SelectLatestInstaller>
<Message Text="%(LatestInstaller.FullPath)" />
</Target>
<UsingTask TaskName="SelectLatestInstaller"
TaskFactory="CodeTaskFactory"
AssemblyFile="$(MSBuildToolsPath)\Microsoft.Build.Tasks.v4.0.dll">
<ParameterGroup>
<Installers ParameterType="System.String[]" Required="true" />
<LatestInstaller ParameterType="System.String" Output="true" />
</ParameterGroup>
<Task>
<Reference Include="System.Linq" />
<Using Namespace="System" />
<Using Namespace="System.Linq" />
<Using Namespace="System.Text.RegularExpressions" />
<Code Type="Fragment" Language="cs">
<![CDATA[
LatestInstaller = Installers
.OrderByDescending(f => Regex.Match(f, #"\\ProductStreamV(?<version>(\d+.){0,3}\d+)\\").Groups["version"].Value)
.FirstOrDefault();
]]>
</Code>
</Task>
</UsingTask>
I am currently using the inbuilt Publish function within VS2012 to publish an ASP.NET MVC site to a file system directory share on a Web Server. Is there anyway that I can have it publish to multiple locations rather than just the one when I click the Publish button?
I don’t want to have to create a second profile and have to do the same process twice and I have looked at modifying the pubxml file by adding in an additional tag to see if the publish routine picks it up. But unfortunately it just seems to pick up the last configuration in the list.
I know the ideal would be to implement a CI solution but for the time being my hands are tied with the Publish functionality and need to keep it relatively straight forward.
Many thanks
We had the same need of publishing our solution to multiple file share locations, and while the question was asked several months ago I thought that an answer could benefit to the community.
Since VS publish profiles are plain MSBuild files that can easily be extended, here is the solution I came with.
Note that I extracted some code fragments from our build process that is a bit more complex so I do not guarantee that it will all works without having to alter it a bit.
In the publish profile, I added a custom DeploymentPaths item as shown below.
Note that you could define one or more additional locations.
<ItemGroup Label="Defines additional publish locations">
<DeploymentPaths Include="\\SERVER1\ShareFolder\ProjectA\" />
<DeploymentPaths Include="\\SERVER2\ShareFolder\ProjectA\" />
</ItemGroup>
Then I added a custom target CustomWebFileSystemPublish to run after WebFileSystemPublish. This target calls another MSBuild file publish.xml that performs the delete of existing files and copy the new files.
<!-- Custom File System Publish to deploy to additional locations based on DeploymentPaths -->
<Target Name="CustomWebFileSystemPublish" AfterTargets="WebFileSystemPublish" Condition=" #(DeploymentPaths)!='' ">
<CreateItem Include="$(MSBuildProjectDirectory)\$(_PackageTempDir)">
<Output ItemName="AbsoluteSourcePathItem" TaskParameter="Include" />
</CreateItem>
<CreateProperty Value="%(AbsoluteSourcePathItem.Fullpath)">
<Output PropertyName="AbsoluteSourcePath" TaskParameter="Value" />
</CreateProperty>
<Message Text="### CustomWebFileSystemPublish" Importance="high" />
<Message Text="### DeploymentPaths: #(DeploymentPaths)" Importance="high" />
<MSBuild Projects="$(MSBuildProjectFile)" Properties="AbsoluteSourcePath=$(AbsoluteSourcePath)" Targets="DoPublish" />
</Target>
<Target Name="DoPublish">
<Message Text="### DoPublish $(AbsoluteOutputPath) | %(DeploymentPaths.Identity)" Importance="normal" />
<!-- Adjust path to the publish.xml file depending on where you put it in your solution -->
<MSBuild Projects="..\Deployment\publish.xml" Properties="OutputPath=$(AbsoluteSourcePath);DeployPath=%(DeploymentPaths.Identity)" />
</Target>
Finally, here is the publish.xml MSBuild file
<!-- Publish.xml -->
<Project ToolsVersion="4.0" DefaultTargets="Default" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="Start">
<PropertyGroup>
<!-- Ensure DeployPath has the expected trailing slash -->
<DeployPath Condition=" '$(DeployPath)' != '' and !HasTrailingSlash('$(DeployPath)') ">$(DeployPath)\</DeployPath>
</PropertyGroup>
<Message Text=" # Deploying from $(OutputPath) to $(DeployPath) " Importance="normal" />
</Target>
<Target Name="CleanDeployFolder" DependsOnTargets="Start"
Condition=" $(DeployPath)!=''">
<Message Text=" # Cleaning files in $(DeployPath)" Importance="normal" />
<!-- Defines the files to clean -->
<ItemGroup>
<DeployCleanFiles Include="$(DeployPath)\**\*.*" />
</ItemGroup>
<!--Delete files in Deploy folder (folders not deleted by Delete Task)-->
<Delete Files="#(DeployCleanFiles)" />
<Message Text=" # Cleaning files in $(DeployPath) Completed" Importance="normal" />
</Target>
<Target Name="CopyToDeployFolder" DependsOnTargets="CleanDeployFolder"
Condition=" $(DeployPath)!=''">
<Message Text=" # Copying files to $(DeployPath)" Importance="normal" />
<ItemGroup>
<OutputFiles Include="$(OutputPath)\**\*.*" />
</ItemGroup>
<Copy SourceFiles="#(OutputFiles)" DestinationFolder="$(DeployPath)%(OutputFiles.RecursiveDir)" />
<Message Text=" # Copying files to $(DeployPath) Completed" Importance="normal" />
</Target>
<Target Name="Default" DependsOnTargets="CopyToDeployFolder"
Condition=" $(OutputPath)!='' And $(DeployPath)!='' ">
<Message Text=" # Deploying from $(OutputPath) to $(DeployPath) Completed" Importance="normal" />
</Target>
</Project>
You could create a small Windows Service that monitors a Directory and copies to multiple locations when new files are added
Try FileSystemWatcher on MSDN
I have upgraded to azure 1.7 and now my build process is broken. I have a script that runs after the build which simply fires cspack as follows.
cspack "C:\Users\MyAppBuild\.hudson\jobs\MyApp Portal Build\workspace\trunk\Portal\SMEEDI.Cloud\ServiceDefinition.csdef"
/role:MyApp.Portal;"C:\Users\MyAppBuild\.hudson\jobs\MyApp Portal Build\workspace\trunk\Portal\Portal\MyApp.Portal\bin"
/sites:"C:\Users\MyAppBuild\.hudson\jobs\MyApp Portal Build\workspace\trunk\Portal\Portal\MyApp.Portal\bin";"MyApp.Portal"
/out:"C:\Users\MyAppBuild\.hudson\jobs\MyApp Portal Build\MyApp.Cloud.cspkg
This is my service definition:
<?xml version="1.0" encoding="utf-8"?>
<ServiceDefinition name="MyApp.Cloud" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2012-05.1.7">
<WebRole name="MyApp.Portal" enableNativeCodeExecution="true">
<ConfigurationSettings>
<Setting name="DiagnosticsConnectionString" />
<Setting name="DataConnectionString" />
<Setting name="BaseUrl" />
<Setting name="DatabaseConnectionString" />
<Setting name="Environment" />
</ConfigurationSettings>
<Sites>
<Site name="MyApp_WebRole" physicalDirectory="..\Portal\MyApp.Portal">
<Bindings>
<Binding name="HttpIn" endpointName="HttpIn" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="HttpIn" protocol="http" port="80" />
</Endpoints>
<Imports>
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
I get the error :
Error: CloudServices7 : The physical directories are not valid for role /sites:C
:\Users\MyAppBuild\.hudson\jobs\MyApp Portal Build\workspace\trunk\Portal\Port
al\MyApp.Portal\bin;MyApp.Portal sites, virtual directories, and virtual appli
cations..
What should the physical directory be?
You may need to use relative path rather than absolute path. Please refer here
When upgrading a project that has relative paths in the csdef (as is the case here) to the 1.8 SDK you should see the warning below in the upgrade log about the change in relative path. This specific change was made to better support parallel builds.
The physicalDirectory attribute of the Site element contains a relative path. This path is relative to the directory in which the target Service Definition file resides when packaged. In previous versions this file was located within the root project directory. In this version, by default, this file is located in the project output directory. You may need to update the relative path to reflect the new location of the target Service Definition file.