Create directory using Nant - nant

Not sure if I'm just totally missing it but I couldn't not figure out how to create a new directory using Nant. Is there built in functionality to do this? Can I just use the command prompt? I tried something along the lines of:
<exec program="cmd" commandline="md c:\test" />
but it just opened up a command prompt on the screen and never finished...

You can use the mkdir task:
<mkdir dir="one/two/three" />

Related

How do I remedy "The "Copy" task does not support copying directories" in azure-devops build step?

From what I've gathered, the only change made since the last build in Azure-DevOps is the version of this nuget-package.
So either there is a mistake made in there (which I am not privy to investigate) or the problem lies elsewhere in the build task.
[error]f:\WorkB_tool\dotnet\sdk\5.0.102\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Publish.targets(237,5):
Error MSB3025: The source file
"C:\windows\ServiceProfiles\NetworkService.nuget\packages\package\version\staticwebassets\css\open-iconic\FONT-LICENSE"
is actually a directory. The "Copy" task does not support copying
directories.
The error is clear enough I suppose, but I havenĀ“t found a resource on what is causing it or how to fix it.
By adding a file ending (css\open-iconic\FONT-LICENSE.txt) the build could proceed.
However, why this was suddenly an issue still perplexes me.
It seems that there is something wrong with Copy Task from your <packages_id>.props file,
Copy task should work with files rather than a folder, so you should use this:
<ItemGroup>
<File Include="$(MSBuildThisFileDirectory)xxx\staticwebassets\assets\libs\flot-charts\Makefile\*.*"></File>
</ItemGroup>
<Target Name="xxx" AfterTargets="xxx">
<Copy SourceFiles="#(File)" DestinationFolder="xxx"></Copy>
</Target>
We could also copy the file via task copy file.

How to execute a PowerShell script only before a web deploy Publish task in VS 2012?

Currently I have a post-build event configured in my web project using Visual Studio 2012 like this:
This basically calls a PowerShell script to add a copyright notice to every .cs file.
What I'd like to do is to execute this powershell script only before Publishing the web app to the remote server. Doing so I won't experience a delay every time I need to debug the project. Do you know of any way of accomplishing this?
According to Sayed's answer, I customized a specific publish profile and added this:
<PipelineDependsOn>
CustomBeforePublish;
$(PipelineDependsOn);
</PipelineDependsOn>
</PropertyGroup>
<Target Name="CustomBeforePublish">
<Message Text="******* CustomBeforePublish *******" Importance="high" />
<Exec Command="powershell.exe -file "$(ProjectDir)\Copyright.ps1"" />
</Target>
It depends on how you define before but below is one technique.
When you create a publish profile with VS2012 it will create you a .pubxml file in the Properties\PublishProfiles folder (My Project\PublishProfiles for VB). These are MSBuild files and you can edit them to customize the publish process. In your case you can inject a target into the publish process, before the publish actually occurs. You can do that by extending the PipelineDependsOn property as below.
<PropertyGroup>
<PipelineDependsOn>
CustomBeforePublish;
$(PipelineDependsOn);
</PipelineDependsOn>
</PropertyGroup>
<Target Name="CustomBeforePublish">
<Message Text="********************************** CustomBeforePublish ***********************************" Importance="high"/>
</Target>
FYI regarding the customization of .wpp.targets, that was the only technique which we had for VS2010. My recommendation here is as follows; customize the .pubxml file for most cases and to only create a .wpp.targets file if you want to customize every publish of the given project.
Sayed's answer nails the problem. However, I thought about providing a fully working answer (testing in Visual Studio 2017):
<PropertyGroup>
<PipelineDependsOn>
PreBuildScript;
$(PipelineDependsOn);
</PipelineDependsOn>
</PropertyGroup>
<Target Name="PreBuildScript">
<Message Text="Executing prebuild script" Importance="high"/>
<Exec Command="powershell.exe -file "$(ProjectDir)\InnerFolder\script.ps1"" />
</Target>
Note: This will execute for both Preview and actual Publish action, so one can find out pre-publish errors before the actual Publish.
Declare the following ProjectName.wpp.targets file in the root of your web application:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<BeforeAddContentPathToSourceManifest>
$(BeforeAddContentPathToSourceManifest);
AddCopyright;
</BeforeAddContentPathToSourceManifest>
</PropertyGroup>
<Target Name="AddCopyright">
<!-- I recommend passing in $(_MSDeployDirPath_FullPath) to your script
as the base path to search to avoid having to perform a VCS rollback
(files are copied there before the deployment)
-->
<Exec Command="powershell.exe -file "$(SolutionDir)Copyright.ps1" "$(_MSDeployDirPath_FullPath)"" />
</Target>
</Project>

FXCop report hosting on Hudson Dashboard Issue

I generated Fxcop analysis report using ant script. But I am unable to host it on Hudson Dashboard.
Using Nant script, I am able to generate an .xml output. Here is the ant:
<target name="Fxcop">
<echo message="Running Fxcop..." />
<exec command="${fxcop.basedir}\FxCopCmd.exe">
<arg value="/f:Path of my source file/>
<arg value="/out:some path/>
</exec>
</target>
In hudson Configuration, To display Vioaltion Reports, i configured the path of output(only pattern) file of the ant in xml file pattern of fxcop.
But Hudson is unable to find it.
I done the configurations and setting correctly.
Can anyone walk me through where I am going wrong.
Thanks in Advance
Most likely XML is created in different subfolder which relative path is originated from current directory. E.g. if your current working directory is %WORKSPACE%\trunk and relative path for report is /out:result\fxcop-result.xml then it will be created in %WORKSPACE%\trunk\result\fxcop-result.xml.
To fix this I suggest to check current directory from which you are executing FxCop analysis (also try searching this xml on build machine).
Easiest way to implement FxCop analysis in Hudson using Windows batch command will be:
Add "Execute Windows batch command" (this command will be executed from base workspace folder, e.g. C:\hudson\workspace\FxCopJob)
Specify command that will execute analysis, e.g.: ""{FxCopDirectory}\fxcopcmd.exe" /file:"%WORKSPACE%\{path to your file}" /directory="{Assemblies_path}" /rulesetdirectory:"{RuleSetDir}" /out:fxcop-result.xml"
Set fxcop-result.xml in fxcop section of Report Violation (e.g. report will be created in C:\hudson\workspace\FxCopJob\fxcop-result.xml)
Run updated Hudson job and verify that FxCop violations are shown
WBR,
Andrey

How to run a custom action after install which can run in quiet or a UI after Install (WIX)

I basically want to able to run an command line tool that already exists on the desired machine against the directory the files were run to.
I.e The Installer does the following:
Specify a location for the files to go into (INSTALLOCATION variable)
Then after copying has finished run a tool which will zip the files and attach them to attach them to another application.
<CustomAction Id="InstallTo" Return="check" Directory="INSTALLLOCATION" Execute="immediate" ExeCommand='"C:\MyTool\Here\Tool.exe" -ad [INSTALLLOCATION] Poop 1.0'/>
<InstallExecuteSequence>
<Custom Action="InstallTo" After="InstallFinalize">$InstallTo>2</Custom>
</InstallExecuteSequence>
At the moment I'm not sure anyuthing is being called, is there a way to basically have this two step install and report progress if the tool failed/doesn't exist etc.
Thanks,
Jamie
Was a problem with our shell library requiring an extra slash.

Nant Copy Task does not copy when run from TeamCity

I have the following target in my nant script:
<target name="update" verbose="true">
<copy todir="${dirs.deploy}">
<fileset basedir="${dirs.drop}\_PublishedWebSites\RomanceReminder.Web">
<include name="**/*.*" />
</fileset>
</copy>
</target>
when I run this script manually the following output is visible in the log:
[nant]
C:\Projects\RomanceReminder\BuildScripts.Custom_test_deploy.build
Buildfile:
file:///C:/Projects/RomanceReminder/BuildScripts.Custom/_test_deploy.build
Target framework: Microsoft .NET
Framework 3.5
Target(s) specified: go
error_check:
stop_w3svc:
cleanup:
[echo] Deleting C:\Webs\Nightly.
update:
[copy] Copying 93 files to
'C:\Webs\Nightly'.
start_w3svc:
go:
BUILD SUCCEEDED
Total time: 2.6 seconds.
As you can see it move 93 files into the web\nightly folder.
When this script is run via TeamCity the copy doesn't happen for some reason. Team city is running under an admin account so it should have all the permissions it needs. The log file for TC show the exact text above except the update task shows nothing.
Anyone have ideas on how I can even troubleshoot this?
UPDATE: I flipped the bit on the copy task to give verbose logging. and now I see the following in my TeamCity log:
[copy] Copying 0 files to 'C:\Webs\Nightly'.
I still am flummoxed by I can run it from the command line and everything works, but TC doesn't copy files... 8(
User Error User Error User Error
Of course, I was not trusting the tool assuming it was doing something wrong. The drop directory is only populated in the package step. This particular script executes before that. Team City destroys the build directory every time it runs including the drop directory. So nant was correct, there were no files to copy. I modified my script to use the build output and all is good with the world.