Hi,

When creating satellite assemblies based on .resources files for specific cultures, I 
ran into some problems with the AlTask. The AlTask always embeds resource with a name 
that is equal to the filename of the resource. Visual Studio uses the namespace as a 
prefix for this name. In other words, the AlTask does the following:

al.exe /embed:d:\devel\somepath\Form1.nl-NL.resources [other arguments]

while VS does the following:

al.exe /embed:d:\devel\somepath\Form1.nl-NL.resources,SomeApp.Form1.nl-NL.resources 
[other arguments]

Naturally, this results in resources not being found by the .NET runtime when running 
the resulting app.

To fix this, I added a Prefix property to AlTask.cs which is added to the filename of 
the embedded resource. So, in order to fix the above example, one has to specify the 
prefix "SomeApp.".  The patch is follows at the end of this message. 

A nicer way to do this is to let AlTask.cs use the ResourceFileSet instead of the 
plain FileSet it uses right now. The ResourceFileSet already has support for prefixes, 
and also has dynamic prefix generation features.

Best,

Arjen

--- AlTask.cs.orig      2003-03-03 20:25:36.000000000 +0100
+++ AlTask.cs   2003-03-12 11:56:04.000000000 +0100
@@ -52,6 +52,7 @@
         string _target = null;       
         string _culture = null;        
         string _template = null;       
+        string _prefix = null;
         FileSet _sources = new FileSet();
 
         /// <summary>The name of the output file for the assembly manifest.
@@ -70,6 +71,12 @@
         ///     This attribute corresponds to the <c>/c[ulture]:</c> flag.</summary>
         [TaskAttribute("culture", Required=false)]
         public string Culture { get { return _culture; } set {_culture = value; } }
+
+        /// <summary>The prefix used for embedding resources.
+               ///             This prefix can be used for specifying a namespace 
when embedding resources. 
+               /// </summary>
+        [TaskAttribute("prefix", Required=false)]
+        public string Prefix { get { return _prefix; } set {_prefix = value; } }
          
         /// <summary>Specifies an assembly from which to get all options except the 
culture field.
         ///     The given filename must have a strong name.
@@ -148,8 +155,15 @@
                         writer.Write(" /template:\"{0}\"", Template);
                     }
 
+                    bool prefixDefined = _prefix != null;
                     foreach (string fileName in Sources.FileNames) {
-                        writer.Write (" /embed:\"{0}\"", fileName);
+                        if (prefixDefined) {
+                            FileInfo fi = new FileInfo(fileName);
+                            writer.Write (" /embed:\"{0},{1}.{2}\"", fileName, 
_prefix, fi.Name);
+                        } else {
+                            writer.Write (" /embed:\"{0}\"", fileName);
+                        }
+
                     }
                     // Make sure to close the response file otherwise contents
                     // Will not be written to disk and ExecuteTask() will fail.


-------------------------------------------------------
This SF.net email is sponsored by:Crypto Challenge is now open!
Get cracking and register here for some mind boggling fun and
the chance of winning an Apple iPod:
http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0031en
_______________________________________________
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to