Skip to content

CopyToOutputDirectory doesn't work if folder name contains @ #11717

@meum

Description

@meum

Describe the bug

If the project folder has @ in the name, files with <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> doesn't get copied to the output directory. This works in 9.0.105, but is broken in 9.0.203.
This causes broken builds for us because Jenkins uses @2 in folder names when the same pipeline is running multiples times in parallel.

To Reproduce

#!/bin/bash

rm -rf consoleapp@2
dotnet new console -o consoleapp@2
cd consoleapp@2
dotnet new globaljson --sdk-version 9.0.203 --roll-forward disable
touch test.txt
cat > consoleapp@2.csproj <<EOF
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>net9.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <None Update="test.txt">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>
</Project>
EOF

dotnet build -v diag
ls bin/Debug/net9.0/test.txt

Fails with ls: cannot access 'bin/Debug/net9.0/test.txt': No such file or directory

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions