简体   繁体   中英

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

Working on a project with WCF services. The project is in git source control.

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.

Currently it seems that every file related to the services is in source control

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

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?

There are two options that we have used:

  1. Ignore the whole service references folder
  2. Ignore all but the References.svcmap

We usually ignore the whole folder that is within the "Service References" folder.

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. The first time any dev pulls on a new machine they have to remove the service reference and re-add it through 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.

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). Then the dev would just have to update the service reference from VS to generate all the other files.

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. (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:

-    <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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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