Editing Project Properties for Publish Version in team build - tfs

i have a nightly build in my TFS server that runs every night and is working completely fine. we plan to create a clickonce application as well which is currently working fine except the publish version (ApplicationVersion) which we want to automatically increment with each build instead of entering it manually. An important point to mention is that we only want the Revision part to be increment by 1 with each build. e.g 1.1.1.1 for first time and 1.1.1.2 for the next build.
Please note as alot of information is available for assembly versioning so i am not at all interested in it, i just want my application version to increment so please do point me in this direction.
My VS and TFS server is 2008.Is there any way i can edit my Publish version before build as i do in this case to edit the InstallUrl of the projecte-g
<File.RegEx Path="$(BuildDirectory)/Sources/Client/Client/Client.csproj"
RegularExpression="<InstallUrl>(.*?)</InstallUrl>"
NewValue="<InstallUrl>$(InstallUrl)</InstallUrl>" Force="true"/>
The publish version is a combination of
<ApplicationVersion>
and
<ApplicationRevision>
and in my scenerio it is defined as follows
<ApplicationRevision>1</ApplicationRevision>
<ApplicationVersion>1.9.4.%2a</ApplicationVersion>
and then
<File.RegEx Path="$(BuildDirectory)/Sources/Client/Client/Client.csproj"
RegularExpression="<ApplicationRevision>(.*?)</ApplicationRevision>"
NewValue="<ApplicationRevision>$(ApplicationRevision)</ApplicationRevision>" Force="true"/>
<File.RegEx Path="$(BuildDirectory)/Sources/Client/Client/Client.csproj"
RegularExpression="<ApplicationVersion>(.*?)</ApplicationVersion>"
NewValue="<ApplicationVersion>$(ApplicationVersion)</ApplicationVersion>" Force="true"/>
But the value is never incremented after first run. after the first run the value is always 1.9.4.1. Is there any way that it should be incremented for the next Build. Have tried application revision with *+1, #+1 ...

You should update your TFS server to TFS 2012 first. This will maintain support for VS2008 (TFS 2013 no longer supports it) and gives you access to community tools that no longer support 2008.
You will find two custom activities in the TFS Community Build Extensions that will do what you need.
ClickOnce - this updates and configures the manifests for clickonce deployments from build
TfsVersion - this creates and populates the versions number with the correct incrementing
No, I do not know any what to do this (except to roll you own) in TFS 2008. It is just too old to be supported by the community.

Related

How to reproduce old/previous builds in TFS Build?

Environment:
TFS 2018 with source code in TFS Git
developers are using gitflow-like workflow (main, develop and short-lived feature branches)
there is a build definition used for CI (off of develop branch)
... and another one for releases (off of main branch)
as project evolves build definitions get updated (new steps, etc)
What is the best approach that allows reproduction of previous builds (or, at minimum, release builds)? (in case if previously made build was lost in boating accident)
Ideally I need to be able to plug in version (e.g. 8.5.12345.1) somewhere, press OK and eventually receive data identical to that produced by corresponding build in the past.
Your best approach is to switch to YAML builds and releases. That way your pipeline is versioned together with the code.
If you don't do that, you may need to clone your build and releases every time you make breaking changes.
Alternatively, use the version diff view in your pipeline to go back to an older version or use the json to create a new definition using the API.
Upgrading to Azure DevOps Servers 2020 will give you more advanced YAML features not yet available in Team Foundation Server 2018.
Note: for truly reproducible builds, you'll need to also find a way to lock the build tasks themselves, TFS and Azure DevOps will automatically roll forward to the latest minor version of a given build task. While task authors should try to prevent any breaking changes in those minor upgrades there are no guarantees. You can also never rely on any tool installers that use a v2.x notation or a task that relies on latest. Azure DevOps isn't ideally suited for full reproducible builds.
You can pin task versions in YAML now, if I remember correctly, this was added in Azure DevOps 2020.
You can set which minor version gets used by specifying the full version number of a task after the # sign (example: GoTool#0.3.1). You can only use task versions that exist for your organization.
See: https://learn.microsoft.com/en-us/azure/devops/pipelines/process/tasks?view=azure-devops&tabs=yaml#task-versions
The Tasks docs offer special scripts to pin the versions of out-of-the-box tasks as well.

Nuget Package Versioning & promoting from CI to Production Nuget feeds

Technologies:
Proget – Nuget Package management server
TFS – On premise 2017 Update 1
Issue:
When re-releasing a build from TFS release, to re-package a CI Nuget package that has already gone to my Proget development feed, there does not appear to be a way to get automatic Semantic versioning.
The help dialog that appears in regards to setting the version within the Nuget packager setup is as follows.
Use Date and Time If you choose 'Use the date and time', this will
generate a SemVer-compliant version formatted as X.Y.Z-ci-datetime
where you choose X, Y, and Z.
Use an Environment Variable If you choose 'Use an environment
variable', you must select an environment variable and ensure it
contains the version number you want to use.
Use the Build Number If you choose 'Use the build number', this will
use the build number to version you package. Note: Under General set
the build format to be
'$(BuildDefinitionName)_$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r)
I’d like to be able to re-release a Nuget package that has gone from my CI build in TFS to my Proget development feed, over into my production Proget feed. Microsoft has a great article on Versioning NuGet packages in a continuous delivery world. In that article they elude to the fact that they are doing something similar, but they aren’t providing any real direction for how it was accomplished.
Question:
How would you configure the Nuget packager so that upon creating the package you would input a build variable? Or is there a way that you could set the major version and just have the minor increment each time? How are others handling the promotion of packages from development to production?
Have tried the following:
Tried $(Version) as a build & release variable, and it doesn’t seem to work. The package gets tagged with the date. Also, this only seems to be really functional in the Build portion of TFS where the modal window contains a spot to modify this value.
Tried using the date & time method, and it sticks CI into the build number. This is almost exactly what we want minus the CI definition. Because it automatically inserts CI, this is not suitable for production.
Turned it off and it pulls the version from the Nuspec, but then this would assume that in your CI build you are always upping the version number to one more than current after you have pushed your last release version. This is because the nuspec is in the build files that you are re-releasing through the TFS release chain. Confusing to say the least.
Use the build number set to $(BuildDefinitionName)$(Year:yyyy).$(Month).$(DayOfMonth)$(Rev:.r) What I’d like here is $(Major).$(Minor).$(Patch). Trying $(Version)$ with a version of 1.0.0 gets you a file named with that has 2017.11.3.1 as the output, seemingly ignoring the $(Version) variable.
Not sure if I totally got your point, seems you would like to create a semantically versioned nupkg after ci process on TFS.
Usually the nupkg should be as shown MSVersioningSample: 1.0.8-ci-20171106-156033.nupkg
However you would like to rename nupgk and republish it to nuget server as the release version simply MSVersioningSample: 1.0.8.nupkg The same as $(Major).$(Minor).$(Patch).
You need to edit NuGetPackager.ps1 in the build agent, change the $VersionRegex value, details you could have a look at the answer in this question: How do I get TFS 2015 to parse 3 digit versioning for NuGet packaging
Also give a try with some 3-rd party extension to handle with Semantic Versioning in TFS build, release task, nuget package, a sample for your reference: Semantic Versioning Build and Release Tasks
Besides just a note: Semantic Versioning 2.0.0 is only supports with NuGet 4.3.0+ and Visual Studio 2017 version 15.3+.

TFS 2017 Build Numbering

We have upgraded from TFS 2013 to TFS 2017, One feature we are trying to implement that we had in 2013 was the ability to have a custom build number. the previous method we had a file called BuildVersion.XML which during the first build step would read the major,minor, and revision and name the build with that build number + 1 on the revision. It would then change then checkout and update the revison number and check in the new version. I know that there are steps where people update the AssemblyInfo. The issue is that not all our code is .net apps. we also now have SSIS Packages, Cordova iOS/android apps, angular sites, aws Lambda functions with node.js which do not have the concept of AssemblyInfo. is there an easy way to implement this?
You can do exactly the same thing in Team Build in TFS 2017.
You can update the build number from any task by calling:
Write-Verbose -Verbose "##vso[build.updatebuildnumber]1.2.3.4"
Add a PowerShell task and add an inline script to read from your file and update the build number with the above.
You can then have additional scripts that use the build number any way you need to version your application.
You can see the full list of logging commands here
https://github.com/Microsoft/vso-agent-tasks/blob/master/docs/authoring/commands.md
You can use my VSTS TFVC tasks to interact with source control, though I do not recommend it. I built these tasks for clients of mine who were doing exactly what you are doing.
Instead of relying on a file in source control it would be a much better solution to pass the BuildNumber from the Build Definition along to the build, have one of your first steps update the files on disk with the correct version number then run your build.
If you manipulate files during the build and check them in you run the risk of inconsistent numbering when you scale up to multiple build agents, it's hard to use in combination with parallel builds and build variable multiplexing and it becomes notoriously hard to do Gated Checkins and Shelveset builds. Plus, it limits your options to move to Git in the future.

Identifying Included Work items in TFS 2015 Release Management

I'm trying to understand the process for vNext Builds and Release Management as far as identifying what work items are included.
If I have a build set up on every check-in (each time a work is completed), then each of those Builds will have one work item linked. I can then trigger a Release deployment of those Builds to a QA environment, but then each Release only identifies that one item as being linked - not any others that have been included since our last production release. Since there could be multiple Release Deploys to QA prior to a Deploy to Production, it's confusing trying to filter through all the Releases.
I'm trying to find a good way to see all work items included in Builds/Releases since the last production deployment. Am I misunderstanding how to use this? Should I be using the same Release and just changing the targeted Build each time? It seems like it bases "included work items" off the checked in work-items in between the last build and the current one.
In Release Management, It compares current release with the last release to show the work items included in current release. You only see one work item is because that you have configured TFS to build every check-in and trigger the release for every build. If you trigger a release after two builds, you will see two work items included in the two builds. The latest version of Visual Studio Team Service has support selecting a release version to compare with current version to list the included changes and work items, but this hasn't been implemented into On-premise TFS yet.
So for now, you can create another release definition and link it to the same build to deploy the build to production manually. Then you can track the included work items from this release definition. Or you can create an app/powershell script to read the build version in the production release and then get the included the work items via Rest API.

How to get code of different version of a web application build on tfs 2008 server

I have been created a web project on tfs server and set a build for this application, which builds the application daily. I want to give a specific version of build to testing team, but if that version was build successfully before two or three days, how can I get the source code of that particular build which was build successfully a few days before.
If I understand correctly, you'll need to roll back to the Changeset you are looking for. This artcile will explain how to do that.
http://msdn.microsoft.com/en-us/library/ms194956(VS.80).aspx

Resources