I have an automated build set up in tfs2015 using a web build definition (i.e. not a xaml build definition) and I am looking to pass a custom property to the msbuild command.
I have tried setting a variable in the definition but this is not used in the build process.
the msbuild command argument that I need to pass is /p:myProperty="bob"
The build definition has variables:
yet when I build I get the msbuild command:
C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe "C:\Build\Agent\_work\5ad80936\FullSolution.sln" /nologo /m /nr:false /fl /flp:"logfile=C:\Build\Agent\_work\5ad80936\FullSolution.sln.log" /dl:CentralLogger,"C:\Build\Agent\agent\worker\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"C:\Build\Agent\agent\worker\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:platform="any cpu" /p:configuration="release"
So the BuildConfiguration and BuildPlatform variables are used in the way I would like myProperty to be used, yet this variable is ignored.
I have tried prefixing my variable name with 'Build', but this made no difference.
Can anyone help?
Incidentally, if run the msbuild command locally and append the required argument the build does exactly what I want.
I have found the answer, the variables are simply that, variables. To use those variables as msbuild command line arguments requires the setting of another part of the build definition:
On the build tab set the MSBuild Arguments parameter to use the variable that you have created:
The part in the $() is the variable name used in the TFS build definition, the portion before the = is the name of the property in your msbuild script. These do not necessarily need be the same
Related
I have a solution that has a Web Site (not a Web Application) and I'm having trouble setting up my Visual Studio Build task.
Usually I setup my MSBuild Arguments like so
/p:DeployOnBuild=true
Then in my Copy Publish Artifact, I e
$(build.sourcesDirectory)/AppSolution/Website/obj/$(BuildConfiguration)/Package/PackageTmp
What MSBuild Arguments do I need to set so that I can make the above work?
The files do not get copied over to the obj/$BuildConfiguration)/Package/PackageTmp folder. So when I go look at the output folder, it just looks like the code files. Not the binaries
Use the MSBuild argument /p:PackageLocation=$(Build.ArtifactStagingDirectory), then publish $(Build.ArtifactStagingDirectory) as an artifact.
We are moving from tfs 2012 to tfs 2018 and converting our XAML build templates to 2015.
For the most part, using the default build template TfvcTemplate12 work well. However when a project references the build number, it fails.
One example is when we use the windows service publish task.
<WindowsServicePublishTask Publish="$(DeployFileService)" ServiceDisplayName="$(ServiceDisplayName)" Destinations="$(ServiceDestinations)" SourcePath="$(OutDir)" BuildNumber="$(BuildNumber)" CreateDropFolder="$(CreateDropFolder)" />
I get the following error
The "WindowsServicePublishTask" task was not given a value for the required parameter "BuildNumber".
How can I reference the build number using TfvcTemplate12?
You are using the wrong environment variables. For XAML build:
TF_BUILD_BUILDNUMBER The build number of the build. For example: CIBuild_20130613.6.
More details please refer TF_BUILD environment variables
You can use the TF_BUILD environment variables to get key bits of data that you need for your build process logic. For example, you can get the path to the source folder or the path to the folder that contains the outputs you want to drop.
TF_BUILD environment variables
Use environment variables in MSBuild
Use environment variables in programs or scripts
Use environment variables in a custom build process
A sample of adding something like the following options to the MSBuild arguments:
/p:DeployOnBuild=true;DeployMethod=Package /p:DefaultPackageOutputDir=”$(TF_BUILD_BINARIESDIRECTORY)”\WebPackage
I have an MSBuild task that populates a variable that I would like to use later in the build process (specifically as an argument in a command line build step).
Is there any way to access an MSBuild variable in subsequent build step?
You can use the ##vso[task.setvariable]value logging command from your MSBuild task to pass the variable to VSO like this:
<Message Text="##vso[task.setvariable variable=myvariable;]$(MyMSBuildProperty)" />
You can use the variable in a subsequent build step by using $(myvariable) in the input fields of the command line build task.
I need to define some fixed version info in my Build Definition, so I thought about setting the MSBuild Arguments option with this version info. However, I don't know how can I get this arguments values in my MSBuild script.
Is it possible?
You get them the same way you get any other MSBuild arguments. So for example if you set the Workflow Argument to:
MSBuild Arguments: /p:foo=99
From your MSBuild script you access it by doing $(foo)
I'm looking to compile my Delphi 2010 project using MSBuild, but something isn't right, I just couldn't make MSBuild to compile my project.
I tried this command line:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "C:\MyProject\Myapp.dproj" /t:Release
and this:
"C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe" "C:\MyProject\Myapp.dproj" /p:Configuration=Release /t:Release
But MSBuild won't recognize my build configuration!
I also changed [ rsvars.bat ] but it didn't work!
#SET BDS=C:\Program Files (x86)\Embarcadero\RAD Studio\7.0
#SET BDSCOMMONDIR=C:\Users\Public\Documents\RAD Studio\7.0
#SET FrameworkDir=C:\Windows\Microsoft.NET\Framework\v4.0.30319
#SET FrameworkVersion=v4.0.30319
#SET FrameworkSDKDir=
#SET PATH=%FrameworkDir%;%FrameworkSDKDir%;%PATH%
#SET LANGDIR=EN
The MSBuild error is:
C:\MyProject\Myapp.dproj : error MSB4057: The target "Release" does
not exist in the project.
Any help to get me build my app with MSBuild would be greatly appreciated.
(Yes, I'm fully aware of tools like FinalBuilder, I just want to learn how to do this with MSBuild)
Thanks!
You need to switch the parameters. The target parameter (/t) tells MSBuild which target to create.
This can be either 'Make', 'Clean' or 'Build' (or a combination of those - seperate them with ';' in this case).
The property parameter (/p) forwards properties to the actual compiler. You can specify for example the configuration using /p:config=
So if you want to clean and then build a project using the release configuration, specify the paramters like this:
msbuild.exe "/t:Clean;Build" "/p:config=Release" Myapp.dproj
Change /p:Configuration=Release to /p:config=Release