简体   繁体   English

WCF服务 - 哪些部分可以从源代码管理中排除?

[英]WCF service - which parts can be excluded from source control?

Working on a project with WCF services. 使用WCF服务处理项目。 The project is in git source control. 该项目采用git源代码控制。

To get a local build of this project working I have had to make config changes basically url endpoint changes to each of the services. 为了使这个项目的本地构建工作,我不得不进行配置更改,基本上url端点更改到每个服务。

Currently it seems that every file related to the services is in source control 目前似乎与服务相关的每个文件都在源代码管理中

*.wsdl, *.xsd, *.svcinfo, reference.cs, *.disco, *.svcmap etc. * .wsdl,*。xsd,* .svcinfo,reference.cs,* .disco,* .svcmap等。

This of course is a nightmare to deal with as I do not want to push these files to the repo. 这当然是一个噩梦,因为我不想将这些文件推送到回购。 So which wcf service-related files can be excluded from git? 那么哪些wcf服务相关文件可以从git中排除?

There are two options that we have used: 我们使用了两种选择:

  1. Ignore the whole service references folder 忽略整个服务引用文件夹
  2. Ignore all but the References.svcmap 忽略除References.svcmap之外的所有内容

We usually ignore the whole folder that is within the "Service References" folder. 我们通常会忽略“Service References”文件夹中的整个文件夹。

This means that when you pull a clean copy of the repo you will see the service reference in the project (since it is a part of the .csproj), but it will throw an error if you try to Update or Configure it. 这意味着当您提取repo的干净副本时,您将在项目中看到服务引用(因为它是.csproj的一部分),但如果您尝试更新或配置它将会引发错误。 The first time any dev pulls on a new machine they have to remove the service reference and re-add it through VS. 任何开发人员第一次使用新机器时,他们必须删除服务引用并通过VS重新添加它。

Our project is set up this way because developers usually develop against their own version of the service (or a common one for issues with multiple devs). 我们的项目是以这种方式设置的,因为开发人员通常会针对他们自己的服务版本(或者针对多个开发者的问题的常见版本)进行开发。 The Reference.svcmap has the service address so this would show up as pending changes in git on any devs machine that was using a service hosted at a different location from the repo's Reference.svcmap. Reference.svcmap具有服务地址,因此这将在使用托管在repo的Reference.svcmap的不同位置的服务的任何开发机器上显示为git中的挂起更改。

You can keep the Reference.svcmap file if everyone using that repo is using the same service (or the service location is only updated between branches). 如果使用该repo的每个人都使用相同的服务(或者仅在分支之间更新服务位置),则可以保留Reference.svcmap文件。 Then the dev would just have to update the service reference from VS to generate all the other files. 然后开发人员只需要从VS更新服务引用以生成所有其他文件。

A caveat to either of these solutions is that, in my experience, the generated files don't always match up, ie when you update/re-add the service reference VS may name the generated file filename 1.xsd instead of filename .xsd. 一个警告到这些解决方案是,在我的经验中,生成的文件并不总是一致的,即当你更新/重新添加服务引用VS可以命名生成的文件 1.xsd,而不是文件名的.xsd 。 (maybe someone else knows what causes this). (也许其他人知道是什么原因造成的)。 Then in the uncommitted changes for git of the .csproj files with the service reference you get a number of: 然后在带有服务引用的.csproj文件的git的未提交更改中,您将获得以下数字:

-    <None Include="Service References\ServiceRef\System.Drawing.xsd">
+    <None Include="Service References\ServiceRef\System.Drawing1.xsd">
-    <None Include="Service References\ServiceRef\service.xsd">
+    <None Include="Service References\ServiceRef\service1.wsd"/>

In our case we just discard those changes (hasn't broken anything so far). 在我们的例子中,我们只是放弃了这些变化(到目前为止还没有破坏)。

这是wcf的某个项目示例请查看gitigonre文件https://github.com/AmaelN/sample.wcf/blob/master/.gitignore

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM