I'm using TeamCity Professional 2020.1.2 .
under a project I have multiple build configurations.
what I want to do is generate a random string in every build of build config "A"
and override it every time, build config "A" runs.
Then I need to use it somewhere in build config "B"
I know how to pass variables between build steps, but I don't know how to do the same between different build configurations.
echo "##teamcity[setParameter name='env.path' value='/sample/path']"
I thought meybe there should be a global parameter registry which every build can read and write from.
Have you tried to use a snapshot dependency between build configurations?
In this case, you can access a parameter from another configuration in the chain by %dep.BUILD_ID.param%.
Here are two related pages in the documentation: "Build dependencies" and "Dependencies properties".
Related
Is it possible to have a workspace mapping that includes paths from two projects in Builds in DevOps?
I have created this mapping in a build in ProjectOne that includes a path from ProjectTwo, but when running the build it will only map the files from ProjectOne:
Yes, it's supported.
Just try to specify the Local path under $(build.sourcesDirectory).
Tested on my side, everything works as expected.
I have a C++ project for which I need to run a custom build tool on some header files to generate code that is required when compiling this project. In general my configuration works. I trigger a build, VS/MSBuild detects whether the output files are up-to-date and runs the custom build tool only if necessary.
However, a problem arises if the build is run in combination with another configuration of the same project. Both configurations depend on the output files of the custom build tool. So if run sequentially only one configuration should trigger the custom build tool to run. For which ever configuration a build is triggered second the output files of the custom build tool are already present and up-to-date. So there is no need to build them again. Unfortunately this is exactly what is happening. Since the custom build tool takes quite some time to run, this increases build times dramatically.
Another interesting aspect is, that once both configuration have run, I can trigger any of them again and the custom build tool is not invoked.
What I would have expected from the documentation is that the custom build tool is triggered:
If any of the files specified as Outputs is missing
If the file for which I specified the custom build tool was modified later than any of the existing files specified as Outputs
If any of the files I specified as Additional Dependencies were modified later than any of the existing files specified as Outputs
But all of this independent from the configuration for which the build was triggered.
Does anyone have an idea on why this might happen? I checked that the settings for the custom build tool are identical for both configurations. The output files are generated into the same folder for both configurations.
The documentation you're referring to is basically correct but it omits to say that everything in there is basically per project configuration/platform because it uses tracker.exe which depends on .tlog files which by default go into the intermediate directory. So as you figured out, making all configurations use the same location for the tlog files should keep the tracker happy and only invoke the custom build tool when needed, independent of configuration/platform. I'm not sure I'd recommend any of this though, sharing temporary object files might cause you problems later.
Another way to deal with this is adding a seperate project with just one configuration, say 'Custom', and do the custom build there. Than make your current project(s) depend on that project and in the solution's Configuration Manager adjust all entries so each configuration you have now builds the 'Custom' configuration for the new project.
I'd like to setup a TeamCity build that will perform an incremental build.
For this, i want to store the build outputs (.dll files) as artifacts, and reuse them on every subsequent build (copy the latest artifacts to the build agent before starting the build).
This will effectively place the last build's artifacts in the project's output folder, so MSBuild could use those artifacts to determine whether it needs to rebuild anything from sources.
I've tried to do this, but it seems TeamCity doesn't allow configuring artifact dependencies from the same build configuration.
For example, if i have a "Build Plugins" configuration that generates a collection of plugin DLLs, i cannot use these as a dependency for the same build configuration...
Is there any inherent way to overcome this in TeamCity, or to create an easy solution myself?
It appears it is only possible to do this when using templates.
You can create a template for a build. Then you create a build from that template. After that you add this build to the artefact dependencies from the template. This allows for circular dependencies.
I have found no other way.
It looks like you can do this now! It seems to work in 9.0.1, and TW-12984 says it should work as far back as 8.1.
I have several projects in my solution, one of which has some test scripts that get copied as part of a post build rule, is there a way to run the post build rule with out doing a "rebuild only" for that project when I want them run?
You could use Custom Build Step instead of post-build event and specify some dummy non-existent Output file. In this case Custom Build Step will run on every build even if project itself is up to date.
Quote from MSDN:
In Outputs, specify the name of the output file. This is a required entry; without a value for this property, the custom build step will not run. If a custom build step has more than one output, separate file names with a semicolon. The name of the output file should be what is specified in the Command Line property. The project build system will look for the file and check its date. If the file is newer than the input file or if the file is not found, then the custom build step will run.
Is this valid?
MSBuild /t=all /configuration=all
I want to build ALL configurations of all projects in a sln file, etc from the command line using MSBuild in Visual Studio 2008.
I do not want to have to specify them when I call MSBuild, the sln/proj files all have that information. I don't want to change my build script if I add configurations to project files.
So for the target I can use BuildAll. If I leave the configuration empty will it build all or is "BuildALL" valid for configuration as well?
EDIT
essentially what I am asking is given an SLN or VCProj file, I want msbuild to iterate all configurations and build it itself, or alternatively some mechanism that will discover them so I don't have to specifically list them on the command line or in a script.
i.e. I don't want to update my build script when I add or remove a configuration. That seems like a pretty reasonable thing to want to do.
You can't by default build all configurations using MSBuild command line options. In order to do this you need to create a new target (VS Project).
The way I do it is:
msbuild /t:BuildAll /Configuration:"Debug;Release;ContinuousIntegration"
I make a standard Target, and call it BuildAll, and for every project I wanted to automate, I'd just create that Target and make it depend on all the targets you want to build automatically.