Hi,

I begin to write support for JSharp project in the solution task.
I test this patch against a big solution (about 20 project, each contains >100 files),
with csharp and jsharp project inside, and it seems to work quite well.


Here is the patch against the today (24/11/2004) cvs :


Laurent.

===========================

diff -ruN nant.org/src/NAnt.VSNet/ConfigurationSettings.cs nant.mine/src/NAnt.VSNet/ConfigurationSettings.cs
--- nant.org/src/NAnt.VSNet/ConfigurationSettings.cs 2004-11-24 18:00:30.471088200 +0100
+++ nant.mine/src/NAnt.VSNet/ConfigurationSettings.cs 2004-11-24 16:59:24.172659400 +0100
@@ -88,6 +88,11 @@
htStringSettings["NoWarn"] = "/nowarn:{0}";
htBooleanSettings["IncrementalBuild"] = "/incremental";
break;
+ case ProjectType.JSharp:
+ htStringSettings["WarningLevel"] = "/warn:{0}";
+ htStringSettings["NoWarn"] = "/nowarn:{0}";
+ htBooleanSettings["IncrementalBuild"] = "/incremental";
+ break;
case ProjectType.VB:
htStringSettings["DefineDebug"] = "/d:DEBUG={0}";
htStringSettings["DefineTrace"] = "/d:TRACE={0}";
diff -ruN nant.org/src/NAnt.VSNet/JSharpProject.cs nant.mine/src/NAnt.VSNet/JSharpProject.cs
--- nant.org/src/NAnt.VSNet/JSharpProject.cs 1970-01-01 01:00:00.000000000 +0100
+++ nant.mine/src/NAnt.VSNet/JSharpProject.cs 2004-11-24 17:29:20.850519200 +0100
@@ -0,0 +1,145 @@
+// NAnt - A .NET build tool
+// Copyright (C) 2001-2004 Gerry Shaw
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 2 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// Gert Driesen ([EMAIL PROTECTED])
+
+using System;
+using System.CodeDom.Compiler;
+using System.Diagnostics;
+using System.Globalization;
+using System.IO;
+using System.Xml;
+
+using NAnt.Core;
+using NAnt.Core.Util;
+
+using NAnt.VSNet.Tasks;
+
+namespace NAnt.VSNet {
+ public class JSharpProject : ManagedProjectBase {
+ #region Public Instance Constructors
+
+ public JSharpProject(SolutionBase solution, string projectPath, XmlElement xmlDefinition, SolutionTask solutionTask, TempFileCollection tfc, GacCache gacCache, ReferencesResolver refResolver, DirectoryInfo outputDir) : base(solution, projectPath, xmlDefinition, solutionTask, tfc, gacCache, refResolver, outputDir) {
+ // ensure the specified project is actually supported by this class
+ if (!IsSupported(xmlDefinition)) {
+ throw new BuildException(string.Format(CultureInfo.InvariantCulture,
+ "Project '{0}' is not a valid J# project.", ProjectPath),
+ Location.UnknownLocation);
+ }
+ }
+
+ #endregion Public Instance Constructors
+
+ #region Override implementation of ProjectBase
+
+ /// <summary>
+ /// Gets the type of the project.
+ /// </summary>
+ /// <value>
+ /// The type of the project.
+ /// </value>
+ public override ProjectType Type {
+ get { return ProjectType.CSharp; }
+ }
+
+ /// <summary>
+ /// Prepares the project for being built.
+ /// </summary>
+ /// <param name="config">The configuration in which the project will be built.</param>
+ /// <remarks>
+ /// Ensures the configuration-level object directory exists and ensures
+ /// that none of the output files are marked read-only.
+ /// </remarks>
+ protected override void Prepare(ConfigurationBase config) {
+ // Visual C#.NET uses the <project dir>\obj\<configuration>
+ // as working directory, so we should do the same to make
+ // sure relative paths are resolved correctly
+ // (eg. AssemblyKeyFile attribute)
+
+ // ensure configuration-level object directory exists
+ if (!config.ObjectDir.Exists) {
+ config.ObjectDir.Create();
+ config.ObjectDir.Refresh();
+ }
+ }
+
+ /// <summary>
+ /// Returns a <see cref="ProcessStartInfo" /> for launching the compiler
+ /// for this project.
+ /// </summary>
+ /// <param name="config">The configuration to build.</param>
+ /// <param name="responseFile">The response file for the compiler.</param>
+ /// <returns>
+ /// A <see cref="ProcessStartInfo" /> for launching the compiler for
+ /// this project.
+ /// </returns>
+ protected override ProcessStartInfo GetProcessStartInfo(ConfigurationBase config, string responseFile) {
+ ProcessStartInfo psi = new ProcessStartInfo(Path.Combine(SolutionTask.
+ Project.TargetFramework.FrameworkDirectory.FullName, "vjc.exe"),
+ "@\"" + responseFile + "\"");
+ psi.WorkingDirectory = config.ObjectDir.FullName;
+ return psi;
+ }
+
+ #endregion Override implementation of ProjectBase
+
+ #region Public Static Methods
+
+ /// <summary>
+ /// Returns a value indicating whether the project represented by the
+ /// specified XML fragment is supported by <see cref="CSharpProject" />.
+ /// </summary>
+ /// <param name="docElement">XML fragment representing the project to check.</param>
+ /// <returns>
+ /// <see langword="true" /> if <see cref="CSharpProject" /> supports
+ /// the specified project; otherwise, <see langword="false" />.
+ /// </returns>
+ /// <remarks>
+ /// <para>
+ /// A project is identified as as C# project, if the XML fragment at
+ /// least has the following information:
+ /// </para>
+ /// <code>
+ /// <![CDATA[
+ /// <VisualStudioProject>
+ /// <CSHARP ... />
+ /// </VisualStudioProject>
+ /// ]]>
+ /// </code>
+ /// </remarks>
+ public static bool IsSupported(XmlElement docElement) {
+ if (docElement == null) {
+ return false;
+ }
+
+ if (docElement.Name != "VisualStudioProject") {
+ return false;
+ }
+
+ XmlNode projectNode = docElement.SelectSingleNode("./VISUALJSHARP");
+ if (projectNode == null) {
+ return false;
+ }
+
+ // TODO: add ProductVersion (and SchemaVersion) check once we add
+ // more specific implementation classes
+ return true;
+ }
+
+ #endregion Public Static Methods
+ }
+}
diff -ruN nant.org/src/NAnt.VSNet/ManagedProjectBase.cs nant.mine/src/NAnt.VSNet/ManagedProjectBase.cs
--- nant.org/src/NAnt.VSNet/ManagedProjectBase.cs 2004-11-24 18:00:30.924059500 +0100
+++ nant.mine/src/NAnt.VSNet/ManagedProjectBase.cs 2004-11-24 17:36:44.763989600 +0100
@@ -299,7 +299,7 @@
Log(Level.Verbose, "Copying references:");


                foreach (ReferenceBase reference in _references) {
-                    if (reference.CopyLocal) {
+                    if (reference.CopyLocal && reference.Name != null) {
                        Log(Level.Verbose, " - " + reference.Name);

Hashtable outputFiles = reference.GetOutputFiles(cs);
diff -ruN nant.org/src/NAnt.VSNet/NAnt.VSNet.csproj nant.mine/src/NAnt.VSNet/NAnt.VSNet.csproj
--- nant.org/src/NAnt.VSNet/NAnt.VSNet.csproj 2004-11-24 18:00:31.236453500 +0100
+++ nant.mine/src/NAnt.VSNet/NAnt.VSNet.csproj 2004-11-24 18:08:07.968756400 +0100
@@ -139,6 +139,11 @@
BuildAction = "Compile"
/>
<File
+ RelPath = "JSharpProject.cs"
+ SubType = "Code"
+ BuildAction = "Compile"
+ />
+ <File
RelPath = "ManagedProjectBase.cs"
SubType = "Code"
BuildAction = "Compile"
diff -ruN nant.org/src/NAnt.VSNet/ProjectBase.cs nant.mine/src/NAnt.VSNet/ProjectBase.cs
--- nant.org/src/NAnt.VSNet/ProjectBase.cs 2004-11-24 18:00:31.252073200 +0100
+++ nant.mine/src/NAnt.VSNet/ProjectBase.cs 2004-11-24 17:11:26.640740200 +0100
@@ -508,6 +508,11 @@
/// <summary>
/// A Visual C++ project.
/// </summary>
- VisualC = 2
+ VisualC = 2,
+
+ /// <summary>
+ /// A Visual J# project.
+ /// </summary>
+ JSharp = 3
}
}
diff -ruN nant.org/src/NAnt.VSNet/ProjectFactory.cs nant.mine/src/NAnt.VSNet/ProjectFactory.cs
--- nant.org/src/NAnt.VSNet/ProjectFactory.cs 2004-11-24 18:00:31.392650500 +0100
+++ nant.mine/src/NAnt.VSNet/ProjectFactory.cs 2004-11-24 17:01:42.808621800 +0100
@@ -115,7 +115,7 @@
string projectFileName = ProjectFactory.GetProjectFileName(path);
string projectExt = Path.GetExtension(projectFileName).ToLower(
CultureInfo.InvariantCulture);
- return projectExt == ".vbproj" || projectExt == ".csproj" || projectExt == ".vcproj";
+ return projectExt == ".vbproj" || projectExt == ".csproj" || projectExt == ".vcproj" || projectExt == ".vjsproj";
}


public static string LoadGuid(string fileName) {
@@ -182,12 +182,17 @@
return new CSharpProject(solution, projectPath, xmlDefinition,
solutionTask, tfc, gacCache, referencesResolver,
outputDir);
+ case ".vjsproj":
+ return new JSharpProject(solution, projectPath, xmlDefinition,
+ solutionTask, tfc, gacCache, referencesResolver,
+ outputDir);
case ".vcproj":
return new VcProject(solution, projectPath, xmlDefinition,
solutionTask, tfc, gacCache, referencesResolver,
outputDir);
}


+
// next, identify project based on XML definition
if (VBProject.IsSupported(xmlDefinition)) {
return new VBProject(solution, projectPath, xmlDefinition,
diff -ruN nant.org/src/NAnt.VSNet/ProjectReference.cs nant.mine/src/NAnt.VSNet/ProjectReference.cs
--- nant.org/src/NAnt.VSNet/ProjectReference.cs 2004-11-24 18:00:31.517608100 +0100
+++ nant.mine/src/NAnt.VSNet/ProjectReference.cs 2004-11-24 17:38:44.547711200 +0100
@@ -61,11 +61,18 @@
string projectFile = solution.GetProjectFileFromGuid(
xmlDefinition.GetAttribute("Project"));


- // load referenced project
- Log(Level.Verbose, "Loading referenced project '{0}'.", projectFile);
- _project = ProjectFactory.LoadProject(solution,
- SolutionTask, projectSettings.TemporaryFiles, gacCache,
- ReferencesResolver, outputDir, projectFile);
+ if (projectFile!=null)
+ {
+ // load referenced project
+ Log(Level.Verbose, "Loading referenced project '{0}'.", projectFile);
+ _project = ProjectFactory.LoadProject(solution,
+ SolutionTask, projectSettings.TemporaryFiles, gacCache,
+ ReferencesResolver, outputDir, projectFile);
+ }
+ else
+ {
+ Log(Level.Verbose, "Missing project file '{0}'.", projectFile);
+ }
}


public ProjectReference(ProjectBase project, ProjectBase parent, bool isPrivateSpecified, bool isPrivate) : base(project.ReferencesResolver, parent) {
@@ -95,7 +102,12 @@
}


        public override string Name {
-            get { return Project.Name; }
+            get
+            {
+                if (Project!=null)
+                    return Project.Name;
+                return null;
+            }
        }

        protected override bool IsPrivate {
@@ -187,16 +199,20 @@
                assemblyReferences = new StringCollection();
            }

- string projectOutputFile = Project.GetConfiguration(
- config.Name).OutputPath;
- if (!File.Exists(projectOutputFile)) {
- throw new BuildException(string.Format(CultureInfo.InvariantCulture,
- "Output file '{0}' of project '{1}' does not exist.",
- projectOutputFile, Project.Name), Location.UnknownLocation);
- }
-
- // add primary output to list of reference assemblies
- assemblyReferences.Add(projectOutputFile);
+ if (Project!=null)
+ {
+ string projectOutputFile = Project.GetConfiguration(
+ config.Name).OutputPath;
+ if (!File.Exists(projectOutputFile))
+ {
+ throw new BuildException(string.Format(CultureInfo.InvariantCulture,
+ "Output file '{0}' of project '{1}' does not exist.",
+ projectOutputFile, Project.Name), Location.UnknownLocation);
+ }
+
+ // add primary output to list of reference assemblies
+ assemblyReferences.Add(projectOutputFile);
+ }


// return assembly references
return assemblyReferences;
diff -ruN nant.org/src/NAnt.VSNet/Resource.cs nant.mine/src/NAnt.VSNet/Resource.cs
--- nant.org/src/NAnt.VSNet/Resource.cs 2004-11-24 18:00:31.626946000 +0100
+++ nant.mine/src/NAnt.VSNet/Resource.cs 2004-11-24 17:04:02.443649800 +0100
@@ -122,6 +122,8 @@
switch (Project.Type) {
case ProjectType.CSharp:
return GetManifestResourceNameCSharp(configSettings, _dependentFile);
+ case ProjectType.JSharp:
+ return GetManifestResourceNameJSharp(configSettings, _dependentFile);
case ProjectType.VB:
return GetManifestResourceNameVB(configSettings, _dependentFile);
default:
@@ -153,7 +155,32 @@
LogicalFile.FullName, dependentFile);
}


- private string GetManifestResourceNameVB(ConfigurationSettings configSetting, string dependentFile) {
+ private string GetManifestResourceNameJSharp(ConfigurationSettings configSetting, string dependentFile)
+ {
+ // defer to the resource management code in CscTask
+ JscTask jsc = new JscTask();
+ jsc.Project = _solutionTask.Project;
+ jsc.NamespaceManager = _solutionTask.NamespaceManager;
+ jsc.OutputFile = new FileInfo(Path.Combine(configSetting.OutputDir.FullName,
+ Project.ProjectSettings.OutputFileName));
+
+ // set-up resource fileset
+ ResourceFileSet resources = new ResourceFileSet();
+ resources.Project = _solutionTask.Project;
+ resources.NamespaceManager = _solutionTask.NamespaceManager;
+ resources.Parent = jsc;
+ resources.BaseDirectory = new DirectoryInfo(Path.GetDirectoryName(Project.ProjectPath));
+ resources.Prefix = Project.ProjectSettings.RootNamespace;
+ resources.DynamicPrefix = true;
+
+ // bug #1042917: use logical location of resource file to determine
+ // manifest resource name
+ return jsc.GetManifestResourceName(resources, InputFile.FullName,
+ LogicalFile.FullName, dependentFile);
+ }
+
+ private string GetManifestResourceNameVB(ConfigurationSettings configSetting, string dependentFile)
+ {
// defer to the resource management code in VbcTask
VbcTask vbc = new VbcTask();
vbc.Project = _solutionTask.Project;
diff -ruN nant.org/src/NAnt.VSNet/SolutionBase.cs nant.mine/src/NAnt.VSNet/SolutionBase.cs
--- nant.org/src/NAnt.VSNet/SolutionBase.cs 2004-11-24 18:00:32.017438500 +0100
+++ nant.mine/src/NAnt.VSNet/SolutionBase.cs 2004-11-24 17:26:42.957828100 +0100
@@ -171,9 +171,11 @@
// HashTable is populated and not at usage time to avoid internal
// errors during build.
if (projectFile == null) {
+ /*
throw new BuildException(string.Format(CultureInfo.InvariantCulture,
"Project with GUID '{0}' must be included for the build to"
+ " work.", projectGuid), Location.UnknownLocation);
+ */
}


            return projectFile;
@@ -478,7 +480,10 @@

foreach (ReferenceBase reference in project.References) {
if (reference is ProjectReference) {
- AddProjectDependency(projectGuid, ((ProjectReference) reference).Project.Guid);
+ if (((ProjectReference) reference).Project != null)
+ {
+ AddProjectDependency(projectGuid, ((ProjectReference) reference).Project.Guid);
+ }
} else {
// check if project actually support the build configuration
ConfigurationBase projectConfig = (ConfigurationBase)




-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. http://productguide.itmanagersjournal.com/
_______________________________________________
NAntContrib-Developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nantcontrib-developer

Reply via email to