How to commit build version to TFS

Answered

I am currently trying  to setup TeamCity on our server to replace our old  CCNET setup.

I am using "File content replacer" to update the build number and it works fine.

My issue is that I need to commit those change into TFS.

Is there any way to easily achieve that behavior, it seems that "File content replacer"  cannot handle it? 

Thanks,

/Eric

0
7 comments

Hello Eric,

Yes indeed, the File content replacer would not check-in the changes; however, you could do so via a custom command line script, for example:

 tf checkin version.txt /noprompt /comment:"Updated version number to %version%"

Would this approach work for you?

0
Avatar
Permanently deleted user

OK, 

Thanks I will try.

/Eric

0
Avatar
Permanently deleted user

Hello,

It took me a while but I was able to commit the changes, unfortunately  the build fails as teamcity wants to revert the file...

[13:29:59] : Step 10/11: Command Line
[13:29:59] : [Step 10/11] Starting: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe" checkout D:\Projects\Test2.7\versioninfo.cs /noprompt
[13:29:59] : [Step 10/11] in directory: D:\Projects\Test2.7
[13:29:59] : [Step 10/11] VersionInfo.cs
[13:29:59] : [Step 10/11] Process exited with code 0
[13:29:59]W: Step 11/11: Checkin Version (Command Line)
[13:29:59] : [Step 11/11] Starting: "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\tf.exe" checkin D:\Projects\Test2.7\versioninfo.cs /noprompt "/comment:"Updated version number to 57""
[13:29:59] : [Step 11/11] in directory: D:\Projects\Test2.7
[13:30:00] : [Step 11/11] Checking in edit: VersionInfo.cs
[13:30:00] : [Step 11/11]
[13:30:00] : [Step 11/11] Changeset #39856 checked in.
[13:30:00] : [Step 11/11] Process exited with code 0
[13:30:00]E: File content replacer
[13:30:01]E: [File content replacer] Failed to revert VersionInfo.cs: java.io.FileNotFoundException: D:\Projects\Test2.7\VersionInfo.cs (Access is denied)
[13:30:01]E: [File content replacer] Failed to revert change JetBrains.FileContentReplacer@24a82f84
[13:30:00]W: [File content replacer] Checkout directory: there's at least 1 file in dirty state.
[13:30:00] : Publishing internal artifacts (1s)

 

Could it be because the file is in read only state ? 

0

Hello Eric,

Please accept my apologies for the delayed response here. 
It appears the issue happens because File content replacer will try to revert the changes done before publishing artifacts stage. If the file is read-only, yes, it could fail the build trying to do so.

Would it maybe be feasible for you to amend the VersionInfo.cs with a command-line script instead of File content replacer?

0
Avatar
Permanently deleted user

Yes I think it might be easier, would be nice to have an option in the File content replacer to commit the changes in the future.

0

Hello Eric,

While committing the changes is a separate logic, I agree that at least having option to not revert the changes in the build feature configuration would be useful. There is a related request regarding this matter: https://youtrack.jetbrains.com/issue/TW-43173, and I have just added an internal reference on this thread there. Please feel free to vote/comment on the link above as you see fit.

0
Avatar
Permanently deleted user

Thanks a lot for your time :) 

0

Please sign in to leave a comment.