Hi All,

(As an aside I'm new to this list)

We've been working with a VS.NET solution that includes an ASP.NET project
and we've been using Nant to create an automated build and test environment.

We had some problems getting a nant build script for the solution and ended
up just exec-ing the devenv.exe. 

I found 2 issues:

1. Using the <slingshot> command through nant always gives a error about
build.basedir. I've tried a couple of combinations but with no luck. the
failing script looks like:

    <target name="Slingshot" description="Use Slingshot">
        <slingshot solution="C:\projects\WebSolution.sln" format="nant"
output="Slingshot.build">
            <parameters>
                <option name="build.basedir" value="."/>
            </parameters>
        </slingshot>
    </target>

if anyone can give me any pointers it would be appreciated.

2. After failing with that we took a look at the Slingshot.exe itself and
this gave an error when compiling project references for the ASP.NET project
within the solution.

We had structured our solution as outlined by the Microsoft roadmap for Team
development of .NET solutions. This meant not allowing VS.NET to
automatically create IIS web directories, under c;\inetpub\wwwroot\, for the
ASP.NET application but instead manually creating a Blank Solution first and
then adding the directory structure beneath it, to give something like;

c:\project\MyNewApp\MyNewAppSolution\MyNewWebApp

and then manually mapping the MyNewWebApp directory to be a virtual
directory under IIS and then adding a new ASP.NET project into the blank
solution using http://localhost/MyNewWebApp as its location.

To cut an increasingly long story short this structure seemed to confuse
Slingshot when it tried to build up the correct path to referenced dlls,
producing the following error:

Unhandled Exception: System.NotSupportedException: The given path's format
is not supported.
   at System.Security.Util.StringExpressionSet.CanonicalizePath(String path,
Boolean needFullPath)
   at System.Security.Util.StringExpressionSet.AddExpressions(String[] str,
Boolean checkForDuplicates, Boolean needFullPath)
   at
System.Security.Permissions.FileIOPermission.AddPathList(FileIOPermissionAcc
ess access, String[] pathListOrig, Boolean checkForDuplicates, Boolean
needFullPath, Boolean copyPathList)
   at
System.Security.Permissions.FileIOPermission..ctor(FileIOPermissionAccess
access, String[] pathList, Boolean checkForDuplicates, Boolean needFullPath)
   at System.IO.Path.GetFullPath(String path)
   at SLiNgshoT.Core.Driver.WriteSolution(SolutionWriter writer, TextWriter
textWriter, String sln, Hashtable parameters, Hashtable uriMap)
   at SLiNgshoT_Console.Main(String[] args)

A bit of investigation showed the error to be at around line 300 in
driver.cs:

path = Path.GetFullPath( solution.SolutionDirectory + "\\" 
                 + project.RelativePath + "\\" + path );

For our ASP.NET project structure project.RelativePath is not a RelativePath
it is absolute.

Adding the following test seems to have fixed it:

if(Path.IsPathRooted(project.RelativePath))
        path = GetWebProjectReferencePath(project.RelativePath, path);
else
        path = Path.GetFullPath( solution.SolutionDirectory + "\\" 
        
+ project.RelativePath + "\\" + path );

where

/// <summary>
/// Use Path of the current reference file, as loaded from the HintPath in
the project file, 
/// and the Project Path to build a correct absolute path to the referenced
file.
/// The method can handle the situations
/// Case 1. where the Reference path is correctly relative to the project
file location
/// Case 2. where the Reference path is relative to the Solution file
location
/// Case 3. where the Reference path is local to the Project File location.
/// </summary>
/// <param name="ProjectPath">The rooted path of the current project</param>
/// <param name="ReferencePath">The path, rooted, relative or filename only,
of the referenced file</param>
/// <returns>A string representing the absolute path of the reference
file</returns>
private static string GetWebProjectReferencePath(string ProjectPath, string
ReferencePath)
{
        string Delimiters = "\\";
        char [] DelimiterArray = Delimiters.ToCharArray();
        string [] Directories = null;

        //nasty hardcoding of Max 100 directory levels
        int MaxDirCount = 100;
        Directories = ProjectPath.Split(DelimiterArray, MaxDirCount);

        //NB. remember to discount the drive letter from the directory count
        //so only count the zero-based GetUpperBound value
        int ProjectDirLevelCount = Directories.GetUpperBound(0);
        string ProjectDrive = Directories[0];
        //get ".." count
        Directories = ReferencePath.Split(DelimiterArray, MaxDirCount);
        string ReferenceAbsolutePath = "";
        int ReferenceDirLevelCount = 0;
        for(int i=0;i<=Directories.GetUpperBound(0);i++)
        {
                if(Directories[i] == "..")
                        ReferenceDirLevelCount++;
                else
                        ReferenceAbsolutePath = ReferenceAbsolutePath + "\\"
+ Directories[i];
        }
        ReferenceAbsolutePath = ProjectDrive + ReferenceAbsolutePath;
        
        /* if we have no directories it must be a local copy - Case 1.
       * if the directory counts match then do the standard path building -
Case 2.
         * otherwise take a view and use one constrcuted using the following
assumptions:
         * a. The reference is on the same drive
         * b. The relative path is always taking us back to the root
directory first.
         * ... Case 3.
       * */
        
        //Case 3.
        if(ReferenceDirLevelCount==0)
                return Path.GetFullPath( ProjectPath + "\\" + ReferencePath
);
        //Case 2.
        else if(ProjectDirLevelCount == ReferenceDirLevelCount)
                return Path.GetFullPath( ProjectPath + "\\" + ReferencePath
);
        //Case 1.
        else
                return ReferenceAbsolutePath;
}



I don't know if this is a known problem, or one that has already been fixed,
but looking at line 140 of source.cs it loks like this would be common to
all ASP.NET projects, but I could easily be wrong about that?

string relativeProjectPath = Path.GetDirectoryName(path);
project.RelativePath = relativeProjectPath;

Being new to the sourceforge/open source world I wouldn't have the foggiest
about how to get this change approved, tested, etc and into the actual
slingshot code rather than my local version.

Regards,

Mike
This email and any files transmitted with it are confidential and are
intended solely for the use of the individual or entity to whom they are
addressed.  This communication represents the originator's personal views
and opinions, which do not necessarily reflect those of Jontek Ltd.  If you
are not the original recipient or the person responsible for delivering the
email to the intended recipient, be advised that you have received this
email in error, and that any use, dissemination, forwarding, printing, or
copying of this email is strictly prohibited.  If you received this email in
error, please immediately notify [EMAIL PROTECTED]


-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program.
Does SourceForge.net help you be more productive?  Does it
help you create better code?  SHARE THE LOVE, and help us help
YOU!  Click Here: http://sourceforge.net/donate/
_______________________________________________
NAntContrib-Developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nantcontrib-developer

Reply via email to