Core: NET Core 3.0.0 - incorrect embedded resource name if resource and code files differ only by extension

Created on 25 Sep 2019  路  5Comments  路  Source: dotnet/core

NET Core 3.0.0 - incorrect embedded resource name if resource and code file names differ only by extension in the same folder

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <EmbeddedResource Include="MyCsFile.xml" />
  </ItemGroup>

</Project>

// in file MyCsFile.cs
namespace NetConsoleApp1
{
    public class FirstClassInTheCsFile
    {
    }
}

// Program.cs
using System;

namespace NetConsoleApp1
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            Console.WriteLine(typeof(FirstClassInTheCsFile).Assembly.GetManifestResourceNames()[0]);
        }
    }
}

Output:

NetConsoleApp1.FirstClassInTheCsFile

Expected:

NetConsoleApp1.MyCsFile.xml

Observed: after cs file or xml file name has been changed just starting the app in debug mode does not build the change into the binaries. Rebuild does.

Most helpful comment

See https://github.com/microsoft/msbuild/issues/4740

The known issue document describes this at https://github.com/dotnet/core/blob/master/release-notes/3.0/3.0-known-issues.md#preview-9.

You basically need to set

<PropertyGroup>
    <EmbeddedResourceUseDependentUponConvention>false</EmbeddedResourceUseDependentUponConvention>
</PropertyGroup>

in the project file

All 5 comments

@JasonCard, could you please help redirect?

Hi @jamshedd, I work on .NET content localization, so I think you may have pinged the wrong person?

cc @rainersigwald @nguerrera

This is a known issue with resources in the 3.0 SDK

See https://github.com/microsoft/msbuild/issues/4740

The known issue document describes this at https://github.com/dotnet/core/blob/master/release-notes/3.0/3.0-known-issues.md#preview-9.

You basically need to set

<PropertyGroup>
    <EmbeddedResourceUseDependentUponConvention>false</EmbeddedResourceUseDependentUponConvention>
</PropertyGroup>

in the project file

Duplicate of microsoft/msbuild#4740

Was this page helpful?
0 / 5 - 0 ratings