All,

I made some changes to the ResGenTask.cs file that I would like reviewed and
committed.  I was having difficulty using this and having the task create my
resource files with the appropriate namespace and in the correct "todir".  For
example:

<resgen output="AMS.${project.client.assembly.name}.Controls."
todir="${project.basedir}\${build.dir}\resources" compile="true">
  <resources>
    <includes
name="${project.basedir}\${project.controls.assembly.name}\**\*.resx" />
  </resources>
</resgen>

I needed the generated resource file from MyControl.resx to have the namespace
and created as: AMS.Client.Controls.MyControl.resource

I also needed to place the output in a build/resources directory (i.e. todir)
which was not happening.

If someone gives me developer access I can commit these changes...

Here are my mods (excuse me for not having diff where I am now) with a brief
explanation:


// Property now returns "" if the private member is null
[TaskAttribute("output", Required=false)]
public string Output { 
  get { 
    if( _output == null ) {
      return "";
    } else {
      return _output; 
    }
  } 
  set {_output = value;} 
}

// Property now returns BaseDirectory if the private member is null.
[TaskAttribute("todir", Required=false)]
public string ToDirectory { 
  get { 
    if( _toDir == null ) {
      return BaseDirectory;
    } else {
      return _toDir; 
    }
  }
  set {_toDir = value;} 
}

// Process a single file or file group
protected override void ExecuteTask() {
  _arguments = "";
  if (Resources.FileNames.Count > 0) {
    foreach ( string filename in Resources.FileNames ) {
      string outputFile = getOutputFile(filename);

      if (NeedsCompiling (filename, outputFile)) {
        if (_arguments.Length == 0) {
          AppendArgument ("/compile");
        }
        AppendArgument (String.Format(" \"{0},{1}\"", filename, outputFile));
      }
    }
  } else {
    // Single file situation
    if (Input == null)
      throw new BuildException("Resource generator needs either an input
attribute, or a non-empty fileset.", Location);

    string inputFile = Path.GetFullPath(Path.Combine (BaseDirectory, Input));
    string outputFile = getOutputFile(inputFile);

    if (NeedsCompiling (inputFile, outputFile)) {
      AppendArgument (String.Format ("\"{0}\" \"{1}\"", inputFile, outputFile));
    }
  }

  if ( _arguments.Length > 0) {
    // call base class to do the work
    base.ExecuteTask();
  }
}

// Determine the full path and extension for the output file
private string getOutputFile(string filename)
{
  FileInfo fileInfo = new FileInfo(filename);
  string outputFile = Path.Combine (ToDirectory, Output) + fileInfo.Name;
  outputFile = Path.ChangeExtension( outputFile, TargetExt );
  return outputFile;
}



-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com - A 128-bit supercerts will
allow you to extend the highest allowed 128 bit encryption to all your 
clients even if they use browsers that are limited to 40 bit encryption. 
Get a guide here:http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0030en
_______________________________________________
Nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to