Nant task: vaultcheckin - Not checking in the correct file

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
Guest

Nant task: vaultcheckin - Not checking in the correct file

Post by Guest » Sun Oct 30, 2005 3:12 pm

Hi, I am trying to do this, using NAnt (and draco.net):

Checkout AssemblyInfo.cs
Update the version in AssemblyInfo.cs
Checkin the updated AssemblyInfo.cs

I'm using a recent nightly build of NAnt and the latest vault nant tasks.

It doesn't seem as though the correct file is being checked back into Vault.

Any help would be appreciated.

Thanks

Jim



This is the output that I get:

Exception updating hidden and working file: Object reference not set to an instance of an object.
[vaultcheckout] Exception of type VaultClientOperationsLib.GetLatestVersionFailedException was thrown.

IncrementAssemblyVersion:

[script] Scanning assembly "mh3ynlfd" for extensions.
Previous version: 1.0.1
New version: 1.0.2

[vaultcheckin] Set working folder for $/MyProject to C:\WINDOWS\TEMP\nant_checkinfor_AssemblyInfo.cs from
[vaultcheckin] AssemblyInfo.cs successfully checked in.
[vaultcheckin] Restoring working folder for $/MyProject to

------------------------

This is what my nant script looks like:

<vaultcheckout url="http://myvaulturl" username="admin" password="admin" repository="Default Repository" path="$/MyProject/AssemblyInfo.cs" failonerror="false" />
<call target="IncrementAssemblyVersion" failonerror="false" />
<vaultcheckin url="http://myvaulturl" username="admin" password="admin" repository="Default Repository" path="$/MyProject/AssemblyInfo.cs" diskfile="${nant.project.basedir}/AssemblyInfo.cs" comment="Automated check-in: Increment assembly version" />

jgeurts
Posts: 6
Joined: Sun Oct 30, 2005 2:42 pm

I am the author...

Post by jgeurts » Sun Oct 30, 2005 3:15 pm

Sorry, i just wanted to reply to this so that I get emails when someone replies to the thread... I am the author of this post and didn't realize I wasn't logged in :|

ian_sg
Posts: 787
Joined: Wed May 04, 2005 10:55 am
Location: SourceGear
Contact:

Post by ian_sg » Tue Nov 01, 2005 8:29 am

It looks like there's an error on the checkout, so that's probably why you're not seeing what you expect on the checkin.

Can you tell me what versions of Vault and NAnt you're using, and which NAnt tasks?
Ian Olsen
SourceGear

ian_sg
Posts: 787
Joined: Wed May 04, 2005 10:55 am
Location: SourceGear
Contact:

Post by ian_sg » Tue Nov 01, 2005 8:32 am

Also, can you verify that the repository path in question ($/MyProject in your example) has a working folder set before the checkout? If this is the problem, we should surely be giving a better error message, but this is possibly the culprit.
Ian Olsen
SourceGear

jgeurts
Posts: 6
Joined: Sun Oct 30, 2005 2:42 pm

Post by jgeurts » Tue Nov 01, 2005 8:40 am

NAnt version: nant-0.85-nightly-2005-10-26
Vault version (server & client): 3.1.3
I have the latest NAnt tasks (downloaded a few days ago)

I'm pretty sure that the repository path does not have a working folder. This is because I'm calling vault from a server with Draco.Net running and I don't really use vault on that machine other than to do nightly builds. Also, the working folder would be different because each build is built to a specific folder.

Can I not check in a file to a repository path that doesn't have a working folder set? That's why I thought I was setting the diskfile property.

Thanks for the help with this!

ian_sg wrote:Also, can you verify that the repository path in question ($/MyProject in your example) has a working folder set before the checkout? If this is the problem, we should surely be giving a better error message, but this is possibly the culprit.

ian_sg
Posts: 787
Joined: Wed May 04, 2005 10:55 am
Location: SourceGear
Contact:

Post by ian_sg » Tue Nov 01, 2005 9:33 am

Okay that's almost certainly the problem. Vaultcheckout doesn't know where to put the file.

If your repository is not set to require exclusive locks (which is the default) you can retrieve the file using vaultgetfile instead, which will let you set a path for the retrieved file:

Code: Select all

<vaultgetfile
  url="http://myvaulturl"
  username="admin"
  password="admin"
  repository="Default Repository"
  path="$/MyProject/AssemblyInfo.cs"
  destination="${nant.project.basedir}" />
You may also need to turn off the read-only attribute on the retrieved file, which I believe can be done with a NAnt core task.

If you're requiring exclusive locks, you'll have to set a working folder before the vaultcheckout, which can't be done from NAnt. So hopefully you're not requiring exclusive locks. :wink:
Ian Olsen
SourceGear

jgeurts
Posts: 6
Joined: Sun Oct 30, 2005 2:42 pm

Post by jgeurts » Wed Nov 02, 2005 11:04 am

Hi Ian,

I tried putting <vaultgetFile> before and then after the <vaultcheckout>. I also tried removing the <vaultcheckout> call. But in each case, I still got the same result that the correct file is not getting checked into Vault.

Maybe I'm mistaken, but this is the logic that went through my head:

I can checkout the file (w/o a working dir).
I can make sure that the file I want to check in exists.
The checkin command will check in the file that I specify, regardless of the working folder.

I guess if it comes down to it, I can set a working folder to some temp dir and move the file that I want to check in to that folder... it just seems like sort of a hack to me.

Thanks again for your help

Jim
ian_sg wrote:Okay that's almost certainly the problem. Vaultcheckout doesn't know where to put the file.

If your repository is not set to require exclusive locks (which is the default) you can retrieve the file using vaultgetfile instead, which will let you set a path for the retrieved file:

Code: Select all

<vaultgetfile
  url="http://myvaulturl"
  username="admin"
  password="admin"
  repository="Default Repository"
  path="$/MyProject/AssemblyInfo.cs"
  destination="${nant.project.basedir}" />
You may also need to turn off the read-only attribute on the retrieved file, which I believe can be done with a NAnt core task.

If you're requiring exclusive locks, you'll have to set a working folder before the vaultcheckout, which can't be done from NAnt. So hopefully you're not requiring exclusive locks. :wink:

bozer
Posts: 3
Joined: Thu Dec 01, 2005 4:45 pm

Having the same issue

Post by bozer » Thu Dec 01, 2005 4:49 pm

I am having the exact same issue when trying to check a file in from NAnt. I am using Vault 3.1.5 and NAnt 0.85 RC3. Tried getting file first, checking out first and setting the working diretory through the vault client. Everytime the checkin runs it acts though it is undoing the checkout and incrementing the version.

ian_sg
Posts: 787
Joined: Wed May 04, 2005 10:55 am
Location: SourceGear
Contact:

Post by ian_sg » Fri Dec 02, 2005 9:11 am

This should work:

1. set the working folder for your NAnt/build user to the location NAnt expects to be working with
2. nant checkout
3. modify the file in the correct location
4. nant checkin

Is this what you've done? If so, would you mind attaching your NAnt script?
Ian Olsen
SourceGear

bozer
Posts: 3
Joined: Thu Dec 01, 2005 4:45 pm

Foud a work around

Post by bozer » Fri Dec 02, 2005 2:09 pm

I was using the same flow that you recommend except I was using the get file command since there is no NAnt task to set a working folder. I am using http://vaultpub.sourcegear.com/build/latest/doc/ as my reference for vault NAnt tasks. It would actually perform a checkin (increment the version number and say who checked in the file and date/time and all that good stuff) but wouldn't actually upload the file. Also, it showed success inside the NAnt log.

Decided just to call the command line from NAnt instead and got everything to work pretty well. If anyone is interested in seeing the NAnt commands let me know and I can upload them. My basic setup is CruiseControl.Net, NAnt, NUnit2, FxCop, Simian, with the Vault as the source control provider. Have been able to get all of it to work and its pretty neat.

jgeurts
Posts: 6
Joined: Sun Oct 30, 2005 2:42 pm

Re: Foud a work around

Post by jgeurts » Fri Dec 02, 2005 3:05 pm

Yeah man, I'm interested in seeing how you got it working... I sort of gave up on this since it was a relatively low priority for me. :)

bozer wrote:I was using the same flow that you recommend except I was using the get file command since there is no NAnt task to set a working folder. I am using http://vaultpub.sourcegear.com/build/latest/doc/ as my reference for vault NAnt tasks. It would actually perform a checkin (increment the version number and say who checked in the file and date/time and all that good stuff) but wouldn't actually upload the file. Also, it showed success inside the NAnt log.

Decided just to call the command line from NAnt instead and got everything to work pretty well. If anyone is interested in seeing the NAnt commands let me know and I can upload them. My basic setup is CruiseControl.Net, NAnt, NUnit2, FxCop, Simian, with the Vault as the source control provider. Have been able to get all of it to work and its pretty neat.

bozer
Posts: 3
Joined: Thu Dec 01, 2005 4:45 pm

Command line calls from NAnt to make this work

Post by bozer » Tue Dec 06, 2005 4:45 pm

Sorry, I meant to post this a few days ago.

<!-- Sets the working folder -->
<exec program="C:\vaultapi\vault.exe" commandline="setworkingfolder ${vault.lib.internal}/ ${path.build} -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />

<!-- Checks out the files -->
<exec program="C:\vaultapi\vault.exe" commandline="checkout ${vault.lib.internal}/file.dll -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />

Next I use the NAnt Vault Task to get other files needed for compilation, that one seems to work good as long as you don't need to modify and check any of those in.

<!-- Check in file -->
<exec program="C:\vaultapi\vault.exe" commandline="checkin ${vault.lib.internal}/file.dll -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />

<!-- Remove working folder association -->
<exec program="C:\vaultapi\vault.exe" commandline="unsetworkingfolder ${vault.lib.internal}/ -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />

jgeurts
Posts: 6
Joined: Sun Oct 30, 2005 2:42 pm

Re: Command line calls from NAnt to make this work

Post by jgeurts » Tue Dec 06, 2005 7:51 pm

Thanks man!
bozer wrote:Sorry, I meant to post this a few days ago.

<!-- Sets the working folder -->
<exec program="C:\vaultapi\vault.exe" commandline="setworkingfolder ${vault.lib.internal}/ ${path.build} -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />

<!-- Checks out the files -->
<exec program="C:\vaultapi\vault.exe" commandline="checkout ${vault.lib.internal}/file.dll -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />

Next I use the NAnt Vault Task to get other files needed for compilation, that one seems to work good as long as you don't need to modify and check any of those in.

<!-- Check in file -->
<exec program="C:\vaultapi\vault.exe" commandline="checkin ${vault.lib.internal}/file.dll -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />

<!-- Remove working folder association -->
<exec program="C:\vaultapi\vault.exe" commandline="unsetworkingfolder ${vault.lib.internal}/ -user ${vault.username} -password ${vault.password} -host ${vault.url} -repository ${vault.repository}" failonerror="false" />

Post Reply