Skip to content

AssignTargetPath task embeds full paths #5137

Open
@tmat

Description

@tmat

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().

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:

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>
  <ItemGroup>
    <EmbeddedResource Include="..\Resources\Resources.resx" Link="$(MSBuildThisFileDirectory)..\Resources\Resources.resx" />
  </ItemGroup>
</Project>

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

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: DebuggabilityIssues impacting the diagnosability of builds, including logging and clearer error messages.Area: TasksIssues impacting the tasks shipped in Microsoft.Build.Tasks.Core.dll.Task: GenerateResourceProblems with the task itself, resgen.exe, and resx resources in general.triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions