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" />
<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
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:
Edited on 10/10/2007 for clarity due to comments made by Steve Trefethen. Thanks, Steve!
Disclaimer The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.