Nant how do I list all the targets in the current project? - nant

I'm constantly trying to remember some of the buried targets in my nant file.
Is there a command that I can run before I run the target that lists the targets?

Do you mean the command parameter -projecthelp, this will show all targets with the descriptions (when specified)
see also the nant site

Related

Azure Pipelines: building a C++ project with outside "Include Directories"

I tried searching with as many different terms as I could and couldn't find exactly what I'm looking for.
I have a C++ Project developed in Visual Studio 2019 and I am trying to build and deploy it in Azure Pipelines. It uses Boost and OpenCV. I skipped trying to include these in Azure Artifacts because of a rabbit hole with Azure CLI errors that took me almost half a day.
So it seems that there is a task to publish pipeline artifacts in the .yml file. How do I do this when my project needs to reference a certain directory, instead of one specific file or .dll? Here are images for how this is configured in Visual Studio:
include directory for boost image
include directory settings for opencv image
Edit: Still trying, see my comment. Thinking about switching over to CircleCI.
I found out what to do. Hopefully no one else wastes as much time as I did.
The key was MSBuild. One needs to first find out the values of $(IncludePath) and $(LibraryPath) by doing the following first in Visual Studio:
Right-click on your project, choose "Properties"
Go to the Build Events tab, and click "Pre-Build Event"
Click on and expand the Command Line row, and click "Edit"
Now click the button that says "Macros>>"
You will see a bunch of different variables and their values. Find the values for LibraryPath and IncludePath, copy and past them into a text file.
Now, assuming you already set up a local agent, follow these steps:
Put the text file in the root folder of where your agent is installed. For me, this was "C:\agents"
Have the first line be "LibraryPath=value" and the other line be "IncludePath=value". Use double slashes for the directory paths.
Rename the file to .env. If the agent is currently running, restart it so it can read in the environment variables it will use during your build.
In the MSBuild task of your pipeline, specify arguments. For my case, it was simply this: /p:IncludePath="C:\Program Files\boost_1_77_0;$(IncludePath)" /p:LibraryPath="$(LibraryPath)"
Run the pipeline. You can check your completed build on the local machine. For me, the path it kept going to was "C:\agents_work\2\s"

How to Set PublishUrl of ClickOnce Application From CommandLine

I am working on a ClickOnce application. I am trying to publish it from command line using this:
msbuild Project.csproj /t:Publish /p:configuration=release;
The problem is I want to set some other properties along with configuration, like 'PublishUrl' etc.
I've tried this:
msbuild Project.csproj /t:Publish /p:configuration=release;publishurl="\\sdmm\publish\"
It builds successfully but the output of that project will be copied to the debug folder of application in app.publish folder.
How should I handle this thing? Thanks.
You could set any property you want from the command line but before doing so, you need to open your .csproj file in some texteditor(notepad etc). Find the property that you want to edit. In your case it is publish url. Remove this property from csproj file.
Then you could do this
msbuild /target:clean,publish /p:publishurl=c:\publish_location\
you must clean the project before you publish it.
Try to change your target to
msbuild /target:clean,rebuild,publish
because property you are overriding (PublishUrl) was not embedded into application file if only "Publish" target is used.

Running script only for an 'Archive' build in Xcode 4

I have a script that I run using osascript from a Run Script Build Phase in Xcode 4. This script does some checks to try and catch any human-error in plists and suchlike.
However, I only really want to run this script when a developer chooses 'Archive' as opposed to running it every time they build.
Is there any way of testing for this situation? Either in Shell Script or Apple Script?
In Xcode 4+, you could run this script as a pre- or post-action script on the "Archive" action. However, pre- and post-action scripts are not considered part of the build itself; their output is not part of the build log, and a failing script will not cause the build to fail.
If you want to include this script as a first-class part of the build, such that its failure will cause the build to fail, then you'll want to do something else. Make a new "External Build System" target, and configure it to run your script. The path to your script can be a relative path, relative to the project root.
Finally, open your main project scheme, and in the "Build" tag add the new checker target, and set it to only be included in the "Archive" action. This should cause your checker script to be run as part of the build only when "Archive" is selected, and if the script returns a non-zero value the build will fail.
Here's a step-by-step visual guide to configure a bash script to run only when archiving a target:
File > New > Target > Other > External Build System
Name the product accordingly and set /bin/bash as the Build tool
Provide the path to the script under Info > Arguments of the newly created target
Product > Scheme > Edit Scheme…, and edit the scheme of the target where you want this script to run before archiving. Under Build, add the External Build System target you added in step 1. Reorder if needed. Then uncheck everything except Archive.
Add a "New Run Script Phase" to your project's "Build Phases"
Move (drag&drop) your script in the right position
Check the "Run script only when installing"
If you don't do 3. the script will run all the time, but if you check that box, it will only run when archiving.
So in latest Xcode (13.3) you can edit your schemes and copy & paste (or drag&drop) your executable script in the run script textfield (see image).
The pre-Action is executed before the Organizer is opened and the post-action is executed after the build landed in the archives list of products. In both cases the build process of archiving will run through beforehand.
A quick test on my own system shows no difference in the detailed script output between straight "Build" and "Build and Archive".
Also, you can't test for the presence (or absence) of the archive, since it only gets created at the very end of the process, when all scripts have been run.
As far as I can see, there is no current option within Xcode 3 to do this. Maybe file an enhancement request with Apple?
While you wait on Apple, the only solution I can offer is to use xcodebuild and xcrun as part of a command-line shell script, where you would know if you are archiving or not. This is not a stay-in-Xcode solution, but it does have a lot of flexibility.
Xcode "Build and Archive" from command line

Run script during Clean / Clean All in Xcode

I have a fairly complex (iPhone SDK) Xcode project, with many targets -- 4 static libs, unit tests, multiple sample apps, a BuildAll that runs a shell script, and a Package that runs another shell script. The "BuildAll" target creates a directory in the project with some subdirectories with contents ready for distribution.
When I click "Clean All," though, Xcode doesn't know to clean my Distribution directory. I'd like it to. I can't seem to find a way to do this -- does anybody know how?
It feels like Clean and Clean All should really just be targets in Xcode, and I should be able to add a "Run Script" phase. Not so, to my knowledge.
BTW, the "BuildAll" target does handle cleaning the Distribution directory, so this is not the end of the world to me. It's just irksome that "Clean All" doesn't actually clean all in my particular case.
You can try to Add > New Target… > Shell Script Target by control-clicking on a Targets node in the Groups & Files.
Then, after double-clicking on a Run Script node you setup any cleanup-scenario using $ACTION variable that can have values clean, install, etc.
And finally, newly created Shell Script Target should be added to the main target as dependency.
You can add an "External Target" that does the cleaning in an external script, and add that target as a dependency of one of your static library targets. Create the target, and drag it under one of your static library targets. Check for the action using the $ACTION environment variable in the script.

Copy file to the App Resources directory if debug configuration is selected

I need to copy a few files into the App's Resources directory during debug builds. I am thinking about using build rules but don't know how to determine if the build is a debug build. I do have a compiler option of "DEBUG" set.
You can use a Run Script build phase to do the copying. All build settings applied when building the target are available via environment variables in your script.
You can determine what configuration is being built via the CONFIGURATION environment variable; you can look at other environment variables like BUILT_PRODUCTS_DIR to determine where to put your resource. If you specify your Run Script build phase's output correctly, it will only be run when the output needs to be brought up to date, not every time you build.
More information on Run Script build phases is available here: Xcode Build System Guide: Build Phases: Run Script Build Phase
The same kind of thing can be done with script build rules, which is useful if you have multiple resources you want to apply this to: You can create a script build rule that matches your extension (e.g. *.myresource) and use the build settings and input files that are passed to your script via environment variables to do the actual copying. If you specify your build rule's output correctly, it will only be run when its input is newer than its output, not every time you build.
More information on script build rules is available here: Xcode Build System Guide: Build Phases: Build Rules