<vssadd dbpath="C:\Projects\BuildingSolution\VSS\srcsafe.ini" user="MyUser" password="MyPassword" path="$/BuildingSolution" verbose="true"
failonerror="true">
<fileset basedir="C:\projects\BuildingSolution\">
<include name="newfile1.txt"/>
</fileset>
</vssadd>
When I step through the code in Visual Studio, I have discovered where the problem is occuring, but not the reason why. The CreateProjectPath is passed a file with the name of "C:\\projects\\BuildingSolution\\newfile1.txt"
The the projects string array is broken down into 3 elements of C: projects newfile1.txt
When the code attempts to walk through the foreach statement if where the problem is occurring. When the newPath is created, the new path becomes "$/BuildingSolution/C:" This of couse throws an Exception on the Database.get_VSSItem(newPath, false) statement.
Since newItem is null, the createProject thinks that c: is a subproject, so it attempts to create it in the call to newItem = currentItem.NewSubproject( project, "NAntContrib vssadd" ); where project is equal to "C:"
What do I need to change in either the code or in my .build file to have this task return the project instance properly so that files can be added to SourceSafe?
Below is the CreateProjectPath source code that I am referring to above.
protected
IVSSItem CreateProjectPath( string file )
{
//Determine relitivity using the base
directory
if (file.StartsWith(AddFileSet.BaseDirectory.FullName))
{
FileInfo fi = new FileInfo(file);
string relativePath,
currentPath;
string[]
projects;
IVSSItem currentItem = null;
relativePath = fi.DirectoryName.Replace(AddFileSet.BaseDirectory.FullName, "").Replace('/', '\\');
if (relativePath[0] == '\\')
{
relativePath = relativePath.Substring( 1, relativePath.Length -
1);
}
projects = relativePath.Split( '\\' );
currentPath =
Path;
currentItem = Database.get_VSSItem( currentPath, false
);
Log(Level.Info, "RelativePath: " +
relativePath);
Log(Level.Info, "BaseDir: " + AddFileSet.BaseDirectory.FullName
);
//Walk the path creating as we
go
foreach( string project in projects )
{
string newPath = string.Format( "{0}/{1}", currentPath, project
);
IVSSItem newItem = null;
//Try to get the next item in the
path
try
{
newItem = Database.get_VSSItem( newPath, false
);
} catch {}
//Create it if it doesn't
exist
if (newItem == null)
{
newItem = currentItem.NewSubproject( project, "NAntContrib vssadd"
);
Log(Level.Info, "Adding VSS Project : " +
newPath);
}
//Move
on
currentItem =
newItem;
currentPath =
newPath;
}
return
currentItem;
} else
{
return
null;
}
}

