ASP.Net Core 发布因无法复制文件而失败

问题描述 投票:0回答:3

我正在尝试将 Web 作业发布到 Azure,但出现一些如下错误。看起来是因为在“Out”之后的路径中它添加了两个反斜杠而不是一个(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

我正在使用 ASP.Net Core 3.1 和 Visual Studio 2019

asp.net-core publish azure-webjobs
3个回答
6
投票

可能是发布路径太长。

这是我所做的步骤:

  1. 重命名您的项目(使其更短)。
  2. 修复其他项目中的依赖项(如果它们引用您重命名的项目)。
  3. 重命名包含项目文件夹。
  4. 从解决方案中删除项目并再次添加(也是为了修复引用)。
  5. 删除发布配置文件。
  6. 清理并重建。
  7. 创建新的发布配置文件。

如果没有帮助 - 可能是游览路径仍然太长。

祝你好运。


0
投票

我遇到了同样的问题,一切正常,无需更改任何内容,在尝试从 Visual Studio 发布 Web 作业时遇到相同的错误。

我通过将目标框架更改为 .Net 5.0 而不是 Net Core 3.1 解决了这个问题。

这些是我解决问题所遵循的步骤:

  1. 右键单击该项目,然后在目标框架下拉列表中选择.NET 5.0。
  2. 清理项目
  3. 关闭视觉工作室
  4. 手动删除文件夹obj和bin
  5. 打开视觉工作室
  6. 右键单击该项目并选择“重建”

当一切编译成功后,尝试再次发布 - 它应该可以工作。

如果您的依赖项尚未与.NET 5.0兼容,我建议您降级到net core 2.0(按照上述步骤),然后将其改回net core 3.1(按照上述步骤)。

我不知道为什么会这样,但至少这对我有用。


0
投票

使用

-o
指定输出。例如,对本地目录使用
dotnet publish -c Release -o dist
应该可以避免重命名任何内容以缩短路径的需要。

© www.soinside.com 2019 - 2024. All rights reserved.