-
-
Notifications
You must be signed in to change notification settings - Fork 88
Description
Problem Definition
When an <EmbeddedResource> item is added to a .csproj, the filenames are converted into the format {project name}.{dotted path} for the manifest resource in the assembly, where "dotted path" is the project-relative path of the embedded resource with slashes turned into periods. For example, if a/b/c.txt is embedded into the dll for project Foo.Bar, the generated name is Foo.Bar.a.b.c.txt. This is accomplished by MSBuild passing the resource flag as /resource:path,name to csc, where path is the actual path to the file and name is this generated name.
rules_dotnet however only passes the resource as /resource:path which turns the name into the last component. So in the example above, the manifest resource is called c.txt. This breaks one of my use-cases because I embed a directory by globbing and use the name of the manifest resource to create a virtual file system in memory.
Solution
I believe MSBuild's approach can be replicated by doing the following:
- Get the full path of the resource.
- Strip the repository root of the target from the start.
- Strip the package path of the target from the start.
- Replace slashes with periods.
- Prepend the
outattribute and a period.
Open Questions
- How does this handle paths outside the project folder, or in Bazel's case, potentially cross-repo resources? I'm not sure what MSBuild does here either. We could just fallback to the current way of doing things in this case.