On the list of the many annoying nuances of Visual Studio is how it adds web
projects to the .sln file.  For instance if I were to create a project of
type 'ASP.Net Web Application'; VS.net (2002/2003) will add among other
things this entry to the solution file (MyApp.sln):
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web",
"http://localhost/Web.csproj";, "{61E62FEB-04CA-4AB7-B833-930F18E9A6FE}"

The problem here is that when you go to build this project using the
<solution> task, the only way NAnt can find the files is through the fully
quallified Url reference and as such uses the WebDAV protocol to pull each
project file down through HTTP.  This poses a problem to most developers who
run Windows 2003 or even Win2k as WebDAV is generally closed up for security
reasons.  Additionally if it is grabbing these files through IIS with the
.Net Framework installed, most of the files such as *.cs have the
HttpForbiddenHandler associated in the machine.config file preventing them
from being downloaded.

The quick work-around is to update your sln by hand in a text editor,
changing the "UniqueName" portion of the entry to have a relative path,
i.e.:
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Web", "Web\Web.csproj",
"{61E62FEB-04CA-4AB7-B833-930F18E9A6FE}"

Visual Studio is happy with this arrangement until such time as you need to
modify the VS.Net Solution.  If you only work with in the projects in the
solution (add/remove/update), it's not updated.  But if you add a New
Project, or update anything at the Solution level, VS will update the .sln
and *correct* this back to the web reference.

I've extended the SolutionTask class to add an attribute:

[TaskAttribute("updatewebreferences", Required=false)]

...and created a new class that will take the current solution file and
update any projects with a UniqueName that are referenced through http(s) to
be a relative path.  So your solution task will look like this:

 <target name="build">
  <solution
   configuration="${config}"
   solutionfile="MyApp.sln"
   verbose="${verbose}"
   updatewebreferences="true"
   />

 </target>


In doing this, it will first take the name of the project file, append a
.webinfo - navigate through all subdirectories of the Project.BaseDirectory,
open all matching .webinfo's and check to see if they contain that
UniqueName in the UrlPath attribute.  This will indicate the correct
location of the .xxproj file.  We take that location in relative terms and
update the sln.

*QUESTION* I've followed the code guidelines on the site, but how do I
actually get this code into SourceForge as an alpha / beta for people to
ridicule, rip-apart, poke holes and flame me on ;-)? I wouldn't want it in
the actual NAnt bits until many people had used in environments different
than my own.

I did some searching on SourceForge for documentation on how to do this, but
inevitably it took me in circles :-(...

Thank you for your help.



JJDL









-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100003ave/direct;at.aspnet_072303_01/01
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to