.NET Framework类库dll在更新Service Fabric服务时始终会更改 [英] .Net Framework Class Library dll always changes when updating Service Fabric services

查看:73
本文介绍了.NET Framework类库dll在更新Service Fabric服务时始终会更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在Service Fabric中运行的无状态.Net Core服务.在我的服务中,我引用了一个针对.Net Framework 4.7.1的类库.我通过VSTS部署了应用程序,并且其中一个构建步骤通过更改来更新服务的应用程序版本. https://docs.microsoft. com/en-us/vsts/build-release/tasks/utility/service-fabric-versioning

I have a stateless .Net Core services running in Service Fabric. In my services, I reference a class library that targets .Net Framework 4.7.1. I deploy the application via VSTS and one of the build steps updates the app version for services with changes. https://docs.microsoft.com/en-us/vsts/build-release/tasks/utility/service-fabric-versioning

一切正常,除了始终会检测到类库的dll文件的更改.即使我没有更改代码库中的任何内容!这将导致构建步骤更改每个服务的版本.不仅是实际具有更新的服务.

Everything works fine except that changes are always detected for the class library's dll-file. Even though I haven't changed anything in the code library! This causes the build step to bump the version of every single service. Not just services that actually has updates.

日志看起来像波纹管. "MyClassLibrary.dll"是一个我没有涉及其中代码的.Net Framework类库.

The logs looks like bellow. 'MyClassLibrary.dll' is a .Net Framework Class Library that I haven't touched the code in.

2018-03-12T11:39:51.1989307Z     Searching service 'MyServicePkg' for 
changes...
2018-03-12T11:39:51.2247570Z         Searching package 'Code' for changes...
2018-03-12T11:39:51.9878149Z             The file 'MyClassLibrary.dll' has 
changed.
2018-03-12T11:39:54.3850926Z           Updated package 'MyServicePkg\Code' 
from version '1.0.0' to '1.0.1'.

我知道代码包中的更改检查是二进制比较.因此,在编译项目时,二进制文件显然会更改.但是,我不知道为什么.我也有针对.Net Standard 2.0的代码库,它们不会导致此问题,因为只有在我实际触摸代码时才能检测到更改.

I'm aware that the check for changes in the code package is binary comparison. So the binary obviously change when the project is compiled. However, I don't know why. I also have code libraries that targets .Net Standard 2.0 and they don't cause this issue as changes are only detected when I actually have touched the code.

我也知道可以手动忽略不应从应用程序包中更新的文件 https://stackoverflow.com/a/34886586 但是,由于部署链是自动化的,因此这不是一个选择.

I'm also aware that it is possible to manually omit files that shouldn't update from the application package https://stackoverflow.com/a/34886586 However, that is not an option since the deployment chain is automated.

所以我有以下问题:

  1. 是什么导致.Net Framework类库的二进制文件更改?
  2. 它与.Net Standard类库有何不同?
  3. 如何解决此问题,以便只有在进行真正的更改时我的服务才会更新?从.Net Framework移植到.Net Standard?

对此事有一些见识,我们深表感谢.

Some insight in the matter is greatly appreciated.

推荐答案

默认情况下,即使您未进行任何更改,编译器也会创建不同的输出.使用确定性编译器标志,以确保具有相同输入的构建产生相同的输出.

By default, the compiler will create different outputs even if you made no changes. Use the deterministic compiler flag to ensure builds with the same inputs produce the same outputs.

因此,您需要在MSBuild参数中指定/p:Deterministic=true参数.

So, you need to specify /p:Deterministic=true argument in MSBuild Arguments.

简单的方法是使用 Azure Service Fabric应用程序构建模板:创建新的构建定义>选择 Azure Service Fabric应用程序模板,然后您会发现,有/p:Deterministic=true /p:PathMap=$(Agent.BuildDirectory)=C:\在Visual Studio构建任务的MSBuild参数中.

The simple way is using Azure Service Fabric Application build template: Create a new build definition > Select Azure Service Fabric Application template, then you will find, there is /p:Deterministic=true /p:PathMap=$(Agent.BuildDirectory)=C:\ in MSBuild Arguments of Visual Studio Build task.

这篇关于.NET Framework类库dll在更新Service Fabric服务时始终会更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆