简体   繁体   中英

Failed to copy file when trying to publish in Visual Studio (2019)

I am trying to publish a C# project according to Microsoft's own guide , however when I try to do this I am met with the following error (when build output log level is set to diagnostic).

Error: Failed to copy file '[path that is over 260 characters]' to '[path that is under 260 characters]'.
Unable to add '[path that is under 260 characters]' to the Web site.
Unable to add file '[subset of path that is under 260 characters]'.
The system cannot find the path specified.

I have abstracted the literal paths to make the error easier to read.

What is happening here?

Enabling Windows Long Paths (Paths over 260 characters) and rebooting will not save you here.

If you are seeing this issue then one solution is move your project such that the paths it tries to copy are not over 260 characters long. Essentially take your project and move it as close to the root of a drive as you possibly can.

There is possibly a better solution out there however I have been unable to find a way to inform Microsoft's Publishing Tool to correctly interpret paths longer than 260.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM