181
181
string fname = finfo.Name;
182
182
string resourceId;
183
CompilerError ce = GetResourceId (env, finfo, ref fname, resgen, out resourceId, monitor);
183
CompilerError ce = GetResourceId (configuration.IntermediateOutputDirectory.Combine (finfo.ResourceId), env, finfo, ref fname, resgen, out resourceId, monitor);
184
184
if (ce != null) {
185
185
CompilerResults cr = new CompilerResults (new TempFileCollection ());
186
186
cr.Errors.Add (ce);
207
207
projectItems.Remove (finfo);
210
string al = configuration.TargetFramework.ClrVersion == ClrVersion.Net_2_0 ? "al2" : "al";
210
string al = configuration.TargetRuntime.GetToolPath (configuration.TargetFramework, "al");
211
211
CompilerError err = GenerateSatelliteAssemblies (resourcesByCulture, configuration.OutputDirectory, al, Path.GetFileName (configuration.OutputAssembly), monitor);
212
212
if (err != null) {
213
213
CompilerResults cr = new CompilerResults (new TempFileCollection ());
222
CompilerError GetResourceId (ExecutionEnvironment env, ProjectFile finfo, ref string fname, string resgen, out string resourceId, IProgressMonitor monitor)
222
CompilerError GetResourceId (FilePath outputFile, ExecutionEnvironment env, ProjectFile finfo, ref string fname, string resgen, out string resourceId, IProgressMonitor monitor)
224
224
resourceId = finfo.ResourceId;
225
225
if (resourceId == null) {
233
233
if (String.Compare (Path.GetExtension (fname), ".resx", true) != 0)
236
if (!IsResgenRequired (fname)) {
237
fname = Path.ChangeExtension (fname, ".resources");
236
if (!IsResgenRequired (fname, outputFile)) {
237
fname = File.Exists (outputFile) ? (string)outputFile : Path.ChangeExtension (fname, ".resources");
308
308
// true if the resx file or any file referenced
309
309
// by the resx is newer than the .resources file
310
public static bool IsResgenRequired (string resx_filename)
310
public static bool IsResgenRequired (string resx_filename, string output_filename)
312
312
if (String.Compare (Path.GetExtension (resx_filename), ".resx", true) != 0)
313
313
throw new ArgumentException (".resx file expected", "resx_filename");
315
string resources_filename = Path.ChangeExtension (resx_filename, ".resources");
317
if (IsFileNewerThan (resx_filename, resources_filename))
320
XmlTextReader xr = null;
323
// <data type="System.Resources.ResXFileRef, System.Windows.Forms" ..>
324
// <value>... filename;.. </value>
326
xr = new XmlTextReader (resx_filename);
327
string basepath = Path.GetDirectoryName (resx_filename);
329
if (xr.NodeType != XmlNodeType.Element ||
330
String.Compare (xr.LocalName, "data") != 0)
333
string type = xr.GetAttribute ("type");
334
if (String.IsNullOrEmpty (type))
337
if (String.Compare (type, "System.Resources.ResXFileRef, System.Windows.Forms") != 0)
340
xr.ReadToDescendant ("value");
341
if (xr.NodeType != XmlNodeType.Element)
344
string value = xr.ReadElementContentAsString ();
346
string [] parts = value.Split (';');
347
if (parts.Length > 0) {
348
string referenced_filename = MSBuildProjectService.FromMSBuildPath (
349
String.Empty, Path.Combine (basepath, parts [0]).Trim ());
350
if (File.Exists (referenced_filename) &&
351
IsFileNewerThan (referenced_filename, resources_filename))
355
} catch (XmlException) {
356
// Ignore xml errors, let resgen handle it
315
if (File.Exists (output_filename))
316
return IsFileNewerThan (resx_filename, output_filename);
317
return IsFileNewerThan (resx_filename, Path.ChangeExtension (resx_filename, ".resources"));
366
320
// true if first is newer than second