TFS 2015 Release Management - Artifact Type: FileShare Error: System.IO.FileNotFoundException: Unable to find the specified file

TFS 2015 Release Management - Artifact Type: FileShare Error: System.IO.FileNotFoundException: Unable to find the specified file

我正在使用 TFS 2015 版本将构建部署到 DEV、QA 和 UAT 环境。 我正在部署 C# WPF 应用程序。

  1. 我对包含的数据库项目进行了更改,现在我在其中包含了“.sql”脚本 我的 Visual Studio 解决方案中的输出目录。我检查 更改,构建通过。
  2. 我在我的发布管道中创建了一个新版本,并使用新的 创建构建。
  3. 问题:我的发布管道在发布时部署失败 步骤 "Download artifacts".

我需要新包含的“.sql”文件来扩展我们的发布管道,因此我需要找到一种方法来包含这些文件。

这是从失败的部署步骤中获取的 "Download artifacts.log" 文件。在新包含的“.sql”文件之前,此步骤将通过。

    2019-09-27T12:43:12.0760185Z Cleaning artifacts directory: C:\ST-BuildAgent\AgentAd128ed82…
    2019-09-27T12:43:12.2244465Z Cleaned artifacts directory: C:\ST-BuildAgent\AgentAd128ed82
    2019-09-27T12:43:12.2263995Z Number of linked artifacts to download: 2
    2019-09-27T12:43:12.2273760Z Starting artifacts download...
    2019-09-27T12:43:12.2390940Z Downloading linked artifact: Application Main - Continuous...
    2019-09-27T12:43:12.2390940Z Downloading artifact of type: Build
    2019-09-27T12:43:12.2400705Z Created artifact folder C:\ST-BuildAgent\AgentAd128ed82\Application Main - Continuous
    2019-09-27T12:43:12.2527650Z Preparing to get the list of available artifacts from build.
    2019-09-27T12:43:12.3631095Z Preparing to download artifact: Application Main - Continuous_20190927.2
    2019-09-27T12:43:12.3699450Z Artifact Type: FileShare
    2019-09-27T12:43:14.8404900Z Preparing to get the list of available artifacts from build.
    2019-09-27T12:43:14.8854090Z Preparing to download artifact: Application Main - Continuous_20190927.2
    2019-09-27T12:43:14.8854090Z Artifact Type: FileShare
    2019-09-27T12:43:15.9234285Z Preparing to get the list of available artifacts from build.
    2019-09-27T12:43:15.9790890Z Preparing to download artifact: Application Main - Continuous_20190927.2
    2019-09-27T12:43:15.9790890Z Artifact Type: FileShare
    2019-09-27T12:43:17.0171085Z Preparing to get the list of available artifacts from build.
    2019-09-27T12:43:17.0551920Z Preparing to download artifact: Application Main - Continuous_20190927.2
    2019-09-27T12:43:17.0551920Z Artifact Type: FileShare
    2019-09-27T12:43:18.0912585Z Preparing to get the list of available artifacts from build.
    2019-09-27T12:43:18.1518015Z Preparing to download artifact: Application Main - Continuous_20190927.2
    2019-09-27T12:43:18.1518015Z Artifact Type: FileShare
    2019-09-27T12:43:18.1879320Z Error: System.IO.FileNotFoundException: Unable to find the specified file.
    2019-09-27T12:43:18.1879320Z    at Microsoft.TeamFoundation.Release.Windows.Implementation.FileSystemFile..ctor(String fullPath)
    2019-09-27T12:43:18.1889085Z    at Microsoft.TeamFoundation.Release.Windows.Implementation.FileSystemDirectory.<>c.<GetFiles>b__8_0(String fullPath)
    2019-09-27T12:43:18.1889085Z    at System.Linq.Enumerable.<>c__DisplayClass7_0`3.<CombineSelectors>b__0(TSource x)
    2019-09-27T12:43:18.1889085Z    at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()
    2019-09-27T12:43:18.1889085Z    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
    2019-09-27T12:43:18.1898850Z    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
    2019-09-27T12:43:18.1898850Z    at Microsoft.TeamFoundation.DevOps.Diagnostics.DiagnosticsPolicyExecutor.Execute[T](Func`1 func, String methodName)
    2019-09-27T12:43:18.1898850Z    at Microsoft.TeamFoundation.Release.ArtifactRepository.FileShare.FileShareArtifact.DownloadArtifact(ArtifactDefinition artifactDefinition, String dropLocation, String localFolderPath)
    2019-09-27T12:43:18.1898850Z    at Microsoft.TeamFoundation.Release.ArtifactRepository.Build.BuildArtifact.DownloadArtifact(BuildArtifact buildArtifact, ArtifactDefinition artifactDefinition, String localFolderPath, BuildHttpClient buildClient, Int32 buildId)
    2019-09-27T12:43:18.1908615Z    at Microsoft.TeamFoundation.Release.ArtifactRepository.Build.BuildArtifact.Download(ArtifactDefinition artifactDefinition, String localFolderPath)
    2019-09-27T12:43:18.1908615Z    at Microsoft.TeamFoundation.Release.ArtifactRepository.Common.AgentArtifactDownloader.Download(ArtifactDefinition artifactDefinition, Uri workingFolder)
    2019-09-27T12:43:18.1908615Z    at Microsoft.TeamFoundation.DistributedTask.Plugin.Release.ReleaseJobExtension.<>c__DisplayClass19_0.<DownloadArtifacts>b__0()
    2019-09-27T12:43:18.1908615Z    at Microsoft.TeamFoundation.Release.Windows.Implementation.RetryExecutor.Execute(Action action)
    2019-09-27T12:43:18.1918380Z    at Microsoft.TeamFoundation.DistributedTask.Plugin.Release.ReleaseJobExtension.DownloadArtifacts(ITaskContext downloadArtifactTaskContext, IJobContext context, IList`1 agentArtifactDefinitions, Uri artifactsWorkingFolder, String teamProjectId, IDictionary`2 savedSettings)
    2019-09-27T12:43:18.1918380Z    at Microsoft.TeamFoundation.DistributedTask.Plugin.Release.ReleaseJobExtension.DownloadArtifactsWrapper(IJobContext context, IJobRequest job, CancellationToken cancellationToken, ITaskContext downloadArtifactTaskContext, String teamProjectId, Uri artifactsWorkingFolder, Int32 releaseId, IDictionary`2 savedSettings)

我试过的 我已经撤消了我的代码更改、签入了更改、构建了应用程序并成功发布了应用程序。在下载工件步骤中成功。

我尝试了两种不同的方法将“.sql”脚本文件放入构建工件文件夹

  1. 我在数据库的 post-build 事件中使用了 XCOPY 命令 将特定文件复制到的构建输出路径的项目 应用程序。
  2. 或者我尝试手动更改“.sql”文件设置 复制到输出目录总是复制

这两种技术都将我想要的文件复制到构建工件中。

请告诉我接下来应该尝试什么。 谢谢

发现问题,

构建工件的文件路径太长...当发布代理启动作业时,它会将所有链接的构建工件拉入构建代理的工作文件夹。

在我的例子中,我正在复制嵌套在名称较长的文件夹中的文件,而脚本文件本身的名称很长。

解决方案

以某种方式缩短文件名。 XCOPY 有一个缩短文件名的开关。这对我来说很好用。

XCOPY /n - 使用 NTFS 短文件名或目录名创建副本。 /n 当您将文件或目录从 NTFS 卷复制到 FAT 卷时,或者当目标文件系统上需要 FAT 文件系统命名约定(即 8.3 个字符)时,需要使用 /n。目标文件系统可以是 FAT 或 NTFS。