dotnet / dotnet/msbuild

ResGen doesn't properly declare its dependency on PrepareResourceNames

Open
#7,020 3 comments 0 reactions 0 assignees View on GitHub
Area: Common Targets Area: Task: GenerateResource triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

It is implied that the `ResGen` target needs to run after `PrepareResourceNames`:
https://github.com/dotnet/msbuild/blob/6278211736efa2b12cd6cae38572692a44889632/src/Tasks/Microsoft.Common.CurrentVersion.targets#L2991-L2992

It is important because CoreResGen relies on the `%(ManifestResourceName)` metadata being set on the `@(EmbeddedResource)` items:
https://github.com/dotnet/msbuild/blob/6278211736efa2b12cd6cae38572692a44889632/src/Tasks/Microsoft.Common.CurrentVersion.targets#L3272

The metadata is being set in the `CreateManifestResourceNames` target:
https://github.com/dotnet/msbuild/blob/6278211736efa2b12cd6cae38572692a44889632/src/Tasks/Microsoft.CSharp.CurrentVersion.targets#L92

**However**, `ResGen` doesn't explicitly declare its dependency on `PrepareResourceNames`, and in fact, it is possible that a poorly written target can cause `ResGen` to run before `PrepareResourceNames`. Here's an example:

```


GenerateResourceToMergeWithCTO

CoreResGen

MergeCtoResource;
PrepareResourceNames;
ResGen;


CreateManifestResourceNames;


PrepareResources;


CoreBuild;








```

Here we can see that `ResGen` runs before `PrepareResourceNames`:
![image](https://user-images.githubusercontent.com/679326/140597251-5160f487-e88d-41bd-916b-b81912fbd23a.png)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.