I'm working a lot on agile .NET project setup right now. One of the standards in this arena is
CruiseControl.Net. We also use
Subversion and
MSBuild, which means we need to use
MSBuild Tasks to use the custom Subversion tasks. The documentation for MSBuildTasks is, well, "Open Sourcey". For the Subversion tasks, not all tasks have example MSBuild fragments. In addition, the descriptions of most properties or classes are just one sentence circular summaries.
For example, if you need to commit just one file inside the MSBuild script, you would use the SvnCommit task. You might do this as part of a depoyment process where you set version numbers on files before creating an installer. This is the snippet that I finally settled on to update just that one file:
<ItemGroup>
<CodeFiles Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<!-- Later on, inside a Target, use this -->
<SvnCommit
Targets="@(CodeFiles)"
Message="$(CCNetLabel)"
Password="pwd"
UserName="user"
/>
The reason for this is that SvnCommit descends from SvnClient, which is too generalized of a base class. For example, the SvnCommit.RepositoryPath property does not work as one might expect. Specifically, in my case, when I specified the RepositoryPath attribute in the msbuild file, I received the following error. It turns out that you should just not specify the RepositoryPath attribute at all (see the documentation for "svn help commit" to see that a URL is not passed in on the command-line, but rather, svn figures out the URL from the working copy).
svn: 'svn://x.y.z/project/trunk' is a URL, but URLs cannot be commit targets
Also, SvnCommit.LocalPath should not be used. It ends up generating a command-line similar to the following, which ends up committing everything in the LocalPath and down. Remember, all I wanted was to update one specific file, so it turns out that the LocalPath attribute is getting in the way here.
svn.exe commit "full\path\to\my\working\directory"
"Properties\AssemblyInfo.cs" --username user --password pwd
--message "1.8.1.2" --non-ineractive --no-auth-cache
To sum up:
- Don't specify the RepositoryPath attribute in an SvnCommit task
- Don't specify the LocalPath attribute in an SvnCommit task
- Specify a ToolPath entry that points to the folder that holds svn.exe if it's not in the default location (c:\Program Files\Subversion\)
- Setting the Verbose attribute does not work because it is defined as a nullable boolean
Edited on 10/10/2007 for clarity due to comments made by Steve Trefethen. Thanks, Steve!