dotnet / dotnet/msbuild

AssignTargetPath task embeds full paths

Open
#5,137 2 comments 0 reactions 0 assignees View on GitHub
Area: Debuggability Area: Task: GenerateResource Area: Tasks triaged
Dominant language
C#
Stars
5.5k
Forks
1.5k
Avg merge
1d 8h
Merged PRs (30d)
141

Description

If an `EmbeddedResource` has `Link` metadata set to a full path, `AssignTargetPath` task uses this full path as the value of `EmbeddedResource.TargetPath` metadata, which in turn is used by `CreateCSharpManifestResourceName` task to calculate a `ManifestResourceName`. This value is used as a resource name in the assembly metadata.

This makes the content of the built binaries dependent on the directory the repository was built from.

In addition `AssignTargetPath` task calls [`Directory.GetCurrentDirectory()`](https://github.com/microsoft/msbuild/blob/e70a3159d64f9ed6ec3b60253ef863fa883a99b1/src/Tasks/AssignTargetPath.cs#L58).

Note: xliff-build task sets `Link` to a full path: https://github.com/dotnet/xliff-tasks/blob/master/src/XliffTasks/Tasks/GatherTranslatedSource.cs#L49

### Steps to reproduce

Build the following project:

```xml


netstandard2.0



```

Directory contents:
```
C:\temp\repro\Resources\Resources.resx // some resources
C:\temp\repro\ClassLibrary1\ClassLibrary1.csproj
```

Command line
```
msbuild /bl
```

### Actual behavior

The .resources file generated to obj directory includes the full (sanitized) path:

`ClassLibrary1.C_.Temp.repro.ClassLibrary1....Resources.Resources.resources`

which also ends up being the manifest resource name embedded in the assembly:

![image](https://user-images.githubusercontent.com/41759/74965250-bcd79b80-53c9-11ea-824d-0254f88b3130.png)

### Expected behavior

The manifest resource name does not include the full path.

### Environment data
`msbuild /version` output:

```
Microsoft (R) Build Engine version 16.6.0-preview-20110-08+b2a011d16 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

16.6.0.11008
```

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.