@@ -14,22 +14,49 @@ type CreateFSharpManifestResourceName public () =
1414( rootNamespace : string ), (* may be null*)
1515( dependentUponFileName : string ), (* may be null*)
1616( binaryStream : System.IO.Stream ) (* may be null*) ) : string =
17+
18+ // The Visual CSharp and XBuild CSharp toolchains transform resource names like this:
19+ // SubDir\abc.resx --> SubDir.abc.resources
20+ // SubDir\abc.txt --> SubDir.abc.txt
21+ //
22+ // For resx resources, both the Visual FSharp and XBuild FSHarp toolchains do the right thing, i.e.
23+ // SubDir\abc.resx --> SubDir.abc.resources
24+ //
25+ // However for non-resx resources, for some reason Visual FSharp does _not_ add the directory name to the resource name.
26+ // It is very unclear where the directory name gets dropped in the Visual FSharp implementation
27+ // - is it in Microsoft.Common.targets, Microfost.FSharp.targets or how the base type CreateCSharpManifestResourceName
28+ // is created and used - who knows, the code is not easy to understand despite it doing something very simple. That's
29+ // the nature of MSBuild/XBuild....
30+ //
31+ // Anyway, dropping the directory name seems like a mistake. But we attempt to replicate the behaviour here
32+ // for consistency with Visual FSharp. This may not be the right place to do this and this many not be consistent
33+ // when cultures are used - that case has not been tested.
34+
35+ let fileName = if fileName.EndsWith( " .resources" , StringComparison.OrdinalIgnoreCase) then fileNameelse Path.GetFileName( fileName)
36+ let linkFileName = if linkFileName.EndsWith( " .resources" , StringComparison.OrdinalIgnoreCase) then linkFileNameelse Path.GetFileName( linkFileName)
37+
1738let embeddedFileName =
1839match linkFileNamewith
1940| null -> fileName
2041| _ -> linkFileName
42+
2143// since we do not support resources dependent on a form, we always pass null for a binary stream
2244// rootNamespace is always empty - we do not support it
23- let cSharpResult =
24- base .CreateManifestName( fileName, linkFileName, " " , dependentUponFileName, null )
45+ let cSharpResult = base .CreateManifestName( fileName, linkFileName, " " , dependentUponFileName, null )
46+ printfn" (fileName,linkFileName,embeddedFileName,rootNamespace) = '%A '" ( fileName, linkFileName, embeddedFileName, rootNamespace)
47+ printfn" cSharpResult = '%s '" cSharpResult
2548// Workaround that makes us keep .resources extension on both 3.5 and 3.5SP1
2649// 3.5 stripped ".resources", 3.5 SP1 does not. We should do 3.5SP1 thing
2750let extensionToWorkaround = " .resources"
28- if embeddedFileName.EndsWith( extensionToWorkaround, StringComparison.OrdinalIgnoreCase)
51+ let fSharpResult =
52+ if embeddedFileName.EndsWith( extensionToWorkaround, StringComparison.OrdinalIgnoreCase)
2953&& not ( cSharpResult.EndsWith( extensionToWorkaround, StringComparison.OrdinalIgnoreCase)) then
3054 cSharpResult+ extensionToWorkaround
31- else
55+ else
3256 cSharpResult
57+
58+ printfn" fSharpResult = '%s '" fSharpResult
59+ fSharpResult
3360
3461
3562override this.IsSourceFile ( filename : string ) =