question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Publish failed due to Unable to copy file

See original GitHub issue

Describe the bug

i’m trying to publish a webjob to Azure but I get some errors like the following. looks like it’s because in the path after ‘Out’ it adds two backslashes instead of one (PubTmp\Out\\app_data).

28>Could not copy "C:\Development\TNG\ActivationService\bin\Release\netcoreapp3.1\TNG.Services.WindowsService.ActivationService.runtimeconfig.json" to "C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\TNG.Services.WindowsService.ActivationService.runtimeconfig.json". Beginning retry 1 in 1000ms. Could not find a part of the path 'C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\TNG.Services.WindowsService.ActivationService.runtimeconfig.json'. 
28>Could not copy "C:\Users\mohsen.rezaei\.nuget\packages\microsoft.extensions.configuration.azureappconfiguration\4.0.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.AzureAppConfiguration.dll" to "C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\Microsoft.Extensions.Configuration.AzureAppConfiguration.dll". Beginning retry 1 in 1000ms. Could not find a part of the path 'C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\Microsoft.Extensions.Configuration.AzureAppConfiguration.dll'. 
28>Could not copy "C:\Users\mohsen.rezaei\.nuget\packages\microsoft.extensions.configuration.environmentvariables\3.1.6\lib\netcoreapp3.1\Microsoft.Extensions.Configuration.EnvironmentVariables.dll" to "C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\Microsoft.Extensions.Configuration.EnvironmentVariables.dll". Beginning retry 1 in 1000ms. Could not find a part of the path 'C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\Microsoft.Extensions.Configuration.EnvironmentVariables.dll'. 
28>Could not copy "C:\Users\mohsen.rezaei\.nuget\packages\microsoft.extensions.dependencyinjection.abstractions\3.1.6\lib\netstandard2.0\Microsoft.Extensions.DependencyInjection.Abstractions.dll" to "C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\Microsoft.Extensions.DependencyInjection.Abstractions.dll". Beginning retry 1 in 1000ms. Could not find a part of the path 'C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\Microsoft.Extensions.DependencyInjection.Abstractions.dll'. 
28>Could not copy "C:\Users\mohsen.rezaei\.nuget\packages\microsoft.extensions.options.configurationextensions\3.1.6\lib\netcoreapp3.1\Microsoft.Extensions.Options.ConfigurationExtensions.dll" to "C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\Microsoft.Extensions.Options.ConfigurationExtensions.dll". Beginning retry 1 in 1000ms. Could not find a part of the path 'C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\Microsoft.Extensions.Options.ConfigurationExtensions.dll'. 
28>Could not copy "C:\Users\mohsen.rezaei\.nuget\packages\system.data.sqlclient\4.8.1\runtimes\unix\lib\netcoreapp2.1\System.Data.SqlClient.dll" to "C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\runtimes\unix\lib\netcoreapp2.1\System.Data.SqlClient.dll". Beginning retry 1 in 1000ms. Could not find a part of the path 'C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\runtimes\unix\lib\netcoreapp2.1\System.Data.SqlClient.dll'. 
28>Could not copy "C:\Development\TNG\ActivationService\bin\Release\netcoreapp3.1\TNG.Services.WindowsService.ActivationService.runtimeconfig.json" to "C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\TNG.Services.WindowsService.ActivationService.runtimeconfig.json". Beginning retry 2 in 1000ms. Could not find a part of the path 'C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\TNG.Services.WindowsService.ActivationService.runtimeconfig.json'. 
28>Could not copy "C:\Users\mohsen.rezaei\.nuget\packages\microsoft.extensions.configuration.azureappconfiguration\4.0.0\lib\netstandard2.0\Microsoft.Extensions.Configuration.AzureAppConfiguration.dll" to "C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\Microsoft.Extensions.Configuration.AzureAppConfiguration.dll". Beginning retry 2 in 1000ms. Could not find a part of the path 'C:\Development\TNG\ActivationService\obj\Release\netcoreapp3.1\PubTmp\Out\\app_data\Jobs\Continuous\TNG.Services.WindowsService.ActivationService\Microsoft.Extensions.Configuration.AzureAppConfiguration.dll'. 

Further technical details

I’m using ASP.Net Core 3.1 and visual studio 2019

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:17 (5 by maintainers)

github_iconTop GitHub Comments

6reactions
Stricniscommented, Jul 6, 2022

@kylemcnee I had the same issue but fixed it thanks to @joeloff comment. You can add these 2 lines to your publish profile to use different (shorter) paths during the publish: <PublishIntermediateTempPath>D:\Temp\VS2019\MyWebJob\Tmp\</PublishIntermediateTempPath> <PublishIntermediateOutputPath>D:\Temp\VS2019\MyWebJob\Out\</PublishIntermediateOutputPath> Hope this helps.

3reactions
kylemcneecommented, Jun 1, 2022

This has been blocking my work for over a year at this point. If you’re reading this, be warned! Do anything you possibly can to avoid working with .NET

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.Net Core Publish failed due to Unable to copy the file
2 Answers 2 · Rename your project (make it shorter). · Fix the dependencies in other projects if they are referencing your renamed...
Read more >
Publish failed due to Unable to copy file · Issue #14994
It appears it is related to the length of the target path when copying file to the TempPub folder. It seems that when...
Read more >
VS 2019: Publish - "Unable to copy file" on many static ...
When publishing, many “Could not copy” and “Unable to copy file” errors happen. This causes the publish to fail. I have tried: ......
Read more >
Publish APP: Copying file failed in publish using Visual ...
Today, I am writing a very known issue Copying file failed in publish using Visual Studio, it comes issue while deleted files remained...
Read more >
Resolved - Publish failed. Check output for more details.
Guys, I've solved the problem. It seems that I did not set the framework to .NET 4.8 before publishing the project on my...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found