msbuild: [VS / MSBuild 17.13]: Files with build action None and CopyToOutputDirectory are no longer copied

Issue Description

I updated my local visual studio from 17.12.4 to 17.13.0. Since then my local build inside visual studio or directly using msbuild is broken. Files with build action None and CopyToOutputDirectory=Always are no longer copied to it’s target path. They are simply missing. I was already able to see whats causing all this. It’s a simple brace in my path. I made a sample app for this. Take a look at this: https://github.com/Mik4sa/msbuild-brace-in-path-error

Steps to Reproduce

To reproduce open the Developer Command Prompt for VS 2022 for example and execute the following command inside the cloned repo: MSBuild.exe ConsoleApp2.sln -t:Build -p:Configuration=Release -v:quiet -m /restore

Check this file for the diagnostic output of that command (in german): diag-log.txt

Expected Behavior

The files should be copied to the output directory.

Actual Behavior

No file is copied to the output directory.

Analysis

As noted above the brace ( in the path is causing this.

Versions & Configurations

  • MSBuild-Version 17.13.9+e0f243f1e für .NET Framework 17.13.9.7704
  • Windows 11 24H2 (Build 26100.3037)
  • AMD64 (x64)

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 2
  • Comments: 16 (4 by maintainers)

Most upvoted comments

I thought that this going to be available in .NET SDK 9.0.3 which isn’t available yet.

Hi @Mik4sa ,

I have checked your repo on the changes from #11237 and it works now. It will be available in net9 (9.0.3xx version).

p.s. Thank you for providing the repro repo , it always simplifies the work on our side!

I confirm that now on SDK 9.0.300 it works fine. Thanks for the fix.

I can confirm my CopyToOutput: Copy if newer was failing with an “@” in my directory name. Removed the “@” and works fine.

(To clarify, failing as in the file was silently not copying to output with no error message)