I am having a problem with embedded resources for a C# project on a build server using MSBuild on the command line. The project works just fine when building and running tests in Visual Studio, but when running MSBuild from the command line I get the following problems when running a test:
System.Resources.MissingManifestResourceException: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure ".Properties.Resources.resources" was correctly embedded or linked into assembly "" at compile time, or that all the satellite assemblies required are loadable and fully signed..
System.Resources.ManifestBasedResourceGroveler.HandleResourceStreamMissing(String fileName) at System.Resources.ManifestBasedResourceGroveler.GrovelForResourceSet(CultureInfo culture, Dictionary`2 localResourceSets, Boolean tryParents, Boolean createIfNotExists, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo requestedCulture, Boolean createIfNotExists, Boolean tryParents, StackCrawlMark& stackMark) at System.Resources.ResourceManager.InternalGetResourceSet(CultureInfo culture, Boolean createIfNotExists, Boolean tryParents) at System.Resources.ResourceManager.GetString(String name, CultureInfo culture) at Properties.Resources.get_SomeResource() in PropertiesResources.Designer.cs:line 87
I have tracked the problem down into the generated IL (I use ildasm). When bulding in Visual Studio, the following is set in the manifest of the assembly:
.mresource public <PROJECTNAME>.Properties.Resources.resources
{
// Offset: 0x00000000 Length: 0x00000236
}
but when building using MSBuild the following output is generated:
.mresource public '../..//Build/<PROJECTNAME>_AnyCPU_Debug_Obj/<PROJECTNAME>.Properties.Resources.resources'
{
// Offset: 0x00000000 Length: 0x00000236
}
as one can see the path to the resource is suddenly part of the resource name.
Does anyone have any ideas how to fix this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…