Azure devops 为什么Azure Devops会更改从Nuget下载的DLL的日期?

Azure devops 为什么Azure Devops会更改从Nuget下载的DLL的日期?,azure-devops,nuget,Azure Devops,Nuget,我注意到EntityFramework.Dll等文件是在当前时间部署的。 我一直在经历,我通过将DLL从我的开发机器复制到覆盖部署的DLL解决了这个问题 是什么导致DLL上的日期发生更改 azure-pipelines.yml是 trigger: - master pool: vmImage: 'VS2017-Win2016' variables: solution: '**/*.sln' buildPlatform: 'Any CPU' buildConfiguration

我注意到EntityFramework.Dll等文件是在当前时间部署的。 我一直在经历,我通过将DLL从我的开发机器复制到覆盖部署的DLL解决了这个问题

是什么导致DLL上的日期发生更改

azure-pipelines.yml是

trigger:
- master

pool:
  vmImage: 'VS2017-Win2016'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Debug'

steps:
- task: NuGetToolInstaller@0

- task: NuGetCommand@2
  inputs:
    restoreSolution: '**\*.sln'
    feedsToUse: config

    nugetConfigPath: 'MyService.ServiceHost/nuget.config'

- task: VSBuild@1
  inputs:
    solution: '$(solution)'
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: VSTest@2
  inputs:
    platform: '$(buildPlatform)'
    configuration: '$(buildConfiguration)'

- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'
    Contents: |
     $(Build.SourcesDirectory)\MyService.ServiceHost\bin\debug\**\*.*

    TargetFolder: '$(build.artifactstagingdirectory)'

- task: PublishBuildArtifacts@1
  inputs:
    artifactName: 'drop'
我的nuget.config引用

还有一个私人频道

[更新]

我尝试将preservestim戳:True添加到CopyFiles@2任务,但没什么区别

- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'
    Contents: |
     $(Build.SourcesDirectory)\MyService.ServiceHost\bin\debug\**\*.*
    TargetFolder: '$(build.artifactstagingdirectory)'
    preserveTimestamp: True
[更新]

利奥建议采取变通办法。 然而,我想知道如何解压文件发布 目前我的发布管道包含

copy C:\azagent\A2\_work\r1\a\_PreMyFolder\drop\MyService.ServiceHost\bin\Debug\*.* "C:\Program Files (x86)\MyCompany\MyService Service"
为什么Azure Devops会更改从Nuget下载的DLL的日期

这是因为preserveTimestamp选项的默认值在中为False

要解决此问题,只需将值更改为
True

- task: CopyFiles@2
  inputs:
  sourceFolder:
  contents: '**' 
  targetFolder: 
  preserveTimestamp: True
更新:

我尝试将preservestim戳:True添加到CopyFiles@2任务,但它 没什么区别

- task: CopyFiles@2
  displayName: 'Copy Files to: $(Build.ArtifactStagingDirectory)'
  inputs:
    SourceFolder: '$(Build.SourcesDirectory)'
    Contents: |
     $(Build.SourcesDirectory)\MyService.ServiceHost\bin\debug\**\*.*
    TargetFolder: '$(build.artifactstagingdirectory)'
    preserveTimestamp: True
当我第一次测试这个问题时,我发现
复制任务
会修改文件的
时间戳
。事实确实如此。并使用选项
preserveTimestamp
找到了解决方案。我以为这就是问题的全部,直到Kirsten Greed回答我这个解决方案不起作用

我不得不再次测试这个问题,发现
PublishBuildArtifacts
任务也会修改文件的
Timestamp
,但是没有像复制任务那样的
preserveTimstamp
选项。我们可以找到一些类似的线程,但没有一个提供解决方案/解决方法

我目前想到的解决方法是,您可以尝试将工件捆绑到压缩的zip文件中,然后在使用它时将其解压缩

因此,我使用了而不是复制任务:

- task: ArchiveFiles@2

  displayName: 'Archive $(Build.SourcesDirectory)\TestSample\TestSample\bin\Debug'

  inputs:

    rootFolderOrFile: '$(Build.SourcesDirectory)\TestSample\TestSample\bin\Debug'

    archiveFile: '$(Build.ArtifactStagingDirectory)/Test.zip'
然后将此zip文件发布为工件:

- task: PublishBuildArtifacts@1

  displayName: 'Publish Artifact: drop'
现在,我可以保留文件的时间戳:


希望这有帮助。

Hi@LeoLiu MSFT我更新了问题。是的,你说得对!我做了更多的测试,发现任务
PublishBuildArtifacts
也会修改时间戳。我为这个问题提供了一个解决方法,您可以检查我的更新答案是否解决了您的问题。谢谢。作为发行版的一部分,如何解压缩文件?我更新了问题。@KirstenGreed,您可以使用任务
提取文件
解压zip文件。谢谢,我会试试的out@KirstenGreed,永远欢迎您:)。如果你对这个问题有任何其他问题,请免费告诉我。哦,天哪,我得等到周末再试试,我弄得一团糟。压力真大!