परिचय
मैं इस दावे से असहमत हूं कि विजुअल स्टूडियो में पर्सफोर्स एकीकरण "भयानक" है। इसके बजाय, मैं इसे परिभाषित करता हूं "बॉक्स अनुभव से बाहर इष्टतम से कम है" :-)। निम्नलिखित खंड परियोजना/समाधान सेटअप के लिए एकीकरण और सिफारिशों की मेरी समझ पर चर्चा करते हैं।
यदि आप स्रोत नियंत्रण एकीकरण के काम के विवरण में रुचि नहीं रखते हैं तो आप इस उत्तर के अंत तक जा सकते हैं जहां मैं वीबल के प्रश्न के उत्तर सारांशित करता हूं।
Disclaimer: The following sections are just educated guesses based on my empirical experience, however I've used the technique over many years in many projects (each project having multiple experimental/trunk/maintenance/release branches, sometimes even multiple solution files, without issues). The disadvantage is that you have to manually update the project files - but the 2 minute investment is amortized over the lifetime of a project pretty nicely IMHO :-).
समाधान बनाम परियोजना
विजुअल स्टूडियो प्रारंभिक समाधान लोडिंग के दौरान दोनों समाधान फ़ाइल और प्रत्येक प्रोजेक्ट फ़ाइल से स्रोत नियंत्रण बाध्यकारी जानकारी का उपयोग करता है। यह बाध्यकारी जानकारी तब name.suo फ़ाइल में संग्रहीत होती है (मान लीजिए कि हम समाधान के रूप में name.sln का उपयोग कर रहे हैं) - ध्यान दें कि suo फ़ाइलें हैं छुपा ध्वज के साथ चिह्नित किया गया है ताकि वे फ़ाइल एक्सप्लोरर में दिखाई न दें (जब तक कि आप "छिपी हुई फ़ाइलें और फ़ोल्डर्स" विकल्प को ओवरराइड नहीं करते)।
The easiest way to re-bind to source control provider if anything goes wrong is to delete the appropriate suo file and reopen solution. After suo file has been created, changes to elements have no effect.
यदि प्रारंभिक समाधान खोलने के दौरान समाधान फ़ाइल में संग्रहीत बाध्यकारी जानकारी और प्रोजेक्ट फ़ाइल में संग्रहीत जानकारी के बीच एक विसंगति है, तो विजुअल स्टूडियो इसे ठीक करने का प्रयास करेगा (कभी-कभी यह आपके निर्णय के लिए भी संकेत देगा कि समाधान में जानकारी या विसंगति को हल करने के लिए परियोजना में जानकारी को "मास्टर" के रूप में इस्तेमाल किया जाना चाहिए):

विजुअल स्टूडियो डीआरवाई का उल्लंघन क्यों कर रहा है (खुद को दोहराएं) सिद्धांत? मुझे पता नहीं है। मुझे लगता है कि इसमें ऐतिहासिक कारण हैं और विजयी स्रोत सुरक्षित :-) नामक उस दुःस्वप्न की जरूरतों के साथ कसकर मिलते हैं।
इसे "सही ढंग से" कैसे सेट करें?
पर्सफोर्स को या तो नए या मौजूदा समाधान/परियोजनाओं को जोड़ते समय, मैं एक खाली समाधान बनाकर हमेशा प्रारंभ करता हूं ("स्रोत-नियंत्रण एक खाली समाधान" अनुभाग देखें)। मैं फिर इस रिक्त समाधान में परियोजनाओं को जोड़ता हूं, एक दूसरे के बाद। इस परियोजना के आधार पर चरण अलग-अलग हैं कि क्या प्रोजेक्ट जोड़ा जा रहा है या नहीं ("स्रोत-नियंत्रण मौजूदा (अनबाउंड) परियोजनाएं" और "स्रोत-नियंत्रण मौजूदा (बाध्य) परियोजनाओं" अनुभाग देखें) या मुझे एक नया निर्माण करने की आवश्यकता है (देखें "स्रोत-नियंत्रण नई परियोजनाओं" खंड)।
एक खाली समाधान स्रोत-नियंत्रित
स्रोत नियंत्रण के लिए एक नया खाली समाधान जोड़ने के लिए, निम्न कार्य करें:
- Start Visual Studio, "New" -> "Project..." -> "Other project types" -> "Blank solution"; fill in solution name and location, "OK" button
- "File" -> "Source Control" -> "Add Solution to Source Control..."
- In the connection dialog enter appropriate P4 server port, client and user (note that view of the selected client must include the location that you picked in step 1)
- "View" -> "Pending Checkins" -> "Check In" -> in the submit dialog instead of hitting the "Submit" button, use "Cancel".
Reason: The "Check In" action will create a new file, "name.vssscc", then add both "name.sln" and "name.vssscc" to Perforce's default changelist; by cancelling the submit dialog we will keep the "add" operation pending and will be able to edit the files before submitting to P4
- Close Visual Studio
Open the name.sln file in your favourite editor (notepad, if you're really desperate :-) ) and add two new lines (SccProjectName0 and SccProvider0) - the blank solution file should now have a source control section as follows:
GlobalSection(SourceCodeControl) = preSolution
SccNumberOfProjects = 1
SccLocalPath0 = .
SccProjectName0 = Tutorial
SccProvider0 = MSSCCI:Perforce\u0020SCM
EndGlobalSection
The values should be chosen as follows:
- SccProjectName0: an arbitrary string that will be displayed in "Change Source Control" dialog as "Server Binding". This name is used to determine what projects/solution files can share the same source control connection. I recommend not using space for this name as escaping rules for spaces are different in solution and project files.
- SccProvider0: hard-coded value "MSSCCI:Perforce\u0020SCM".
- Submit the two pending files using the Perforce client of your choice (p4.exe, P4Win, P4V)
अब आप बाइंडिंग का परीक्षण कर सकते हैं:
- Make sure Visual Studio is closed
- Delete **all* files except the name.sln (especially the name.suo)
- Open Visual Studio and use it to open name.sln
- A connection dialog should appear, use appropriate port/client/user and click OK
- Solution explorer should now display the solution node with a padlock overlay icon:

- You can now verify source control status of the solution by using "File" -> "Source Control" -> "Change Source Control...":
Note: The column "Server Binding" is showing the value we chose for "SccProjectName0".
स्रोत-नियंत्रण नई परियोजनाओं
यदि आप एक नई परियोजना बना रहे हैं और तुरंत इसे पेर्सफोर्स डिपो में ट्रैक करना शुरू करना चाहते हैं, तो इन चरणों का पालन करें:
- Open the source-controlled solution in Visual Studio
- "File" -> "Add" -> "New Project..." - pick the project type you're adding, name and location (location should be a subdirectory of the directory where the solution file is stored)
- "File" -> "Save All" (this will commit all in-memory changes to solution file and the newly created project file to the disk)
Manually edit the project file you just created using an editor of your choice (come on, notepad AGAIN? ;-) ). Add the following property elements into a PropertyGroup (any property group):
...
Tutorial
..\..
MSSCCI:Perforce SCM
...
The values should be chosen as follows:
- SccProjectName - this is the value that is displayed in "Change Source Control" dialog as "Server Binding"; should be the same as the value you used for SccProjectName0 in blank solution; if not the same, solution and this project won't be able to share the same source control provider connection
- SccLocalPath - relative path to the reference directory (displayed in "Change Source Control" dialog as "Local binding"); because I recommend using the solution directory as the reference directory, this is in effect relative path from directory containing project file to directory containing solution file (my example is storing projects in "(solutionDir)/Source/ProjectName/projectName.csproj", thus the relative path is "two levels up")
- SccProvider - hard-coded value "MSSCCI:Perforce SCM"; this is used to determine what SCCAPI provider are the Scc* binding values valid for
Switch back to Visual Studio; it should automatically detect that the project file has been updated externally and offer to reload it (if not, unload and reload the project manually)
- "View" -> "Pending Checkins"
- "Check In" -> I recommend right-clicking on (solutionName).vssscc file and selecting "Revert if unchanged" (even though Visual Studio opens it for edit, it remains unchanged); provide description and submit the change
यह सत्यापित करने के लिए कि नई जोड़ी गई परियोजना ठीक से बाध्य है, आप इन चरणों का पालन कर सकते हैं:
- Make sure Visual Studio is closed
- Delete (solutionName).suo file as well as MSSCCPRJ.SCC (in solution directory)
- Open Visual Studio and use it to open (solutionName).sln
- A connection dialog should appear, use appropriate port/client/user and click OK
- Solution explorer should now display the project node with a padlock overlay icon:

You can now verify source control status of the solution by using "File" -> "Source Control" -> "Change Source Control...":

One thing to note about this status screenshot is that when I selected the solution row, all the remaining rows were "selected" as well (blue highlight). This is because all those entries have the same "Server Binding" + "Local Binding" and thus share the same source-control-provider (P4) connection.
Also note that "Relative Path" for both projects has two levels, and are relative to the same "Local Binding" - the directory where solution file resides.
मौजूदा (अनबाउंड) परियोजनाओं को स्रोत-नियंत्रित करना
यदि आपके पास ऐसी मौजूदा परियोजनाएं हैं जिनका उपयोग अभी तक किसी अन्य पर्सफोर्स समाधान में नहीं किया गया है, तो उन्हें इन चरणों का पालन करें ताकि उन्हें पर्सफोर्स में जोड़ा जा सके (यानी उन परियोजनाओं को आयात करना जो पहले (इंटरनेट डाउनलोड इत्यादि) स्रोत-नियंत्रित नहीं हैं या एक अलग स्रोत नियंत्रण का उपयोग कर रहे थे प्रदाता (दृश्य स्रोत सुरक्षित, आदि)।
- Copy the project into appropriate location
- Clean-up existing source control bindings (if any):
- Remove existing project-file bindings, i.e. all properties starting with "Scc"
- Delete file (projectName).vspscc in the same directory as the project file (if any)
- Open the source-controlled solution in Visual Studio
- "File" -> "Add" -> "Existing project..." - browse to the project (the copy you created in step 1)
- "File" -> "Save All" (this will commit all in-memory changes to solution file)
- Follow the steps 4-7 from "स्रोत-नियंत्रण नई परियोजनाओं" (i.e. you will now add "Scc*" property elements into a PropertyGroup)
Verification steps are exactly the same as in "स्रोत-नियंत्रण नई परियोजनाओं" section.
मौजूदा (बाध्य) परियोजनाओं को स्रोत-नियंत्रित करना
यदि आपके पास ऐसी परियोजनाएं हैं जो यहां चर्चा की गई तकनीक का उपयोग करके पहले से ही बलफोर्स से बंधी हुई हैं और आप उन्हें एक अलग समाधान (नई शाखा, परियोजना का पुन: उपयोग करने का वैकल्पिक समाधान इत्यादि) में उपयोग करना चाहते हैं, तो निम्न चरणों का उपयोग करें:
- Integrate the project into desired location
- Open the source-controlled solution in Visual Studio
- "File" -> "Add" -> "Existing project..." - browse to the project created in step 1 via integration
- "View" -> "Pending Checkins" -> "Check In" - add description and submit
सारांश
- Source control binding information is stored in both solution and projects, must be in sync (if not, Visual Studio will attempt to fix any discrepancies)
- I always treat project files as the primary source of binding information and solution files as throwaway files that can be recreated easily by first एक खाली समाधान स्रोत-नियंत्रित and then adding desired projects
- Solution file should always have valid SccProvider0
विजुअल स्टूडियो के साथ पर्सफोर्स का उपयोग P4CONFIG पर्यावरण चर का उपयोग कर सरलीकृत किया जा सकता है।
Basically you go into Visual Studio, Tools -> Options -> Source Control -> Plug-in Settings, Advanced button. This will bring up a Perforce configuration dialog specific to the SCC integration. Switch to the Connection tab, and check the radio button titled 'Bind the workspace that matches your Perforce environment settings'. This will tell perforce to prefer using P4CONFIG environment variable for determining the environment you are under. This same dialog exists in P4V under Edit -> Preferences, but only affects p4v's behavior.
आप P4CONFIG पर्यावरण परिवर्तक को कैसे सेट करते हैं, यह कुछ डिग्री तक आपके ऊपर है। मुझे उन्हें हर जगह एक ही नाम दिया जाना पसंद है, इसलिए मैंने p4config.cfg नाम की फ़ाइल देखने के लिए एक सिस्टम-व्यापी पर्यावरण परिवर्तनीय P4CONFIG सेट किया है। यह फ़ाइल सिर्फ एक आईएनआई स्टाइल फ़ाइल है, जहां आप अन्य चर जैसे P4USER, P4CLIENT, P4HOST इत्यादि असाइन कर सकते हैं। Perforce इस फ़ाइल को वर्तमान निर्देशिका में और सभी मूल निर्देशिकाओं में तब तक खोजेगा जब तक कि यह किसी से मुकाबला न करे। असल में आप इस फ़ाइल को मूल रूप से अपनी निर्देशिका में डालते हैं जहां आपके क्लाइंटपेक को आपके हार्ड ड्राइव पर मैप किया गया है, और इसे अकेला छोड़ दें।
यह दृष्टिकोण कार्य करने के क्रम में दृश्य स्टूडियो में एससीसी कॉन्फ़िगरेशन की आवश्यकता वाले 'शुद्धता' की मात्रा को बहुत कम करता है। (एसएके बाइंडिंग ठीक काम करते हैं आदि)
यदि पहली बार या पूरी तरह से स्वच्छ निर्देशिका संरचना के लिए अपने कोड को समन्वयित करने के बाद, और अस्थायी रूप से ऑफ़लाइन काम करने या बाइंडिंग को हटाने के लिए एक बल प्राप्त करने के बारे में शिकायत प्राप्त करने के बाद, अभी भी कुछ संपादन करने की आवश्यकता है। मुख्य रूप से। एसएलएन फ़ाइल को स्वयं संशोधित करने की आवश्यकता होती है, इसलिए यह जानता है कि एसएलएन के पास स्वयं के लिए एससीसी बाइंडिंग है। यह सुनिश्चित करके किया जाता है कि निम्नलिखित फ़ील्ड्स SsNumberOfProjects के बाद .sln फ़ाइल में रखे गए हैं।
SccProjectName0 = Perforce\u0020Project
SccProvider0 = MSSCCI:Perforce\u0020SCM
सभी व्यक्तिगत परियोजनाओं को डिफ़ॉल्ट 'एसएके बाइंडिंग' के साथ ठीक काम करना चाहिए बशर्ते आप पी 4 कॉनफिग दृष्टिकोण का उपयोग कर रहे हों। इसे ठीक करने से पर्सफोर्स को एक साफ सिंक से पूरी तरह से काम करने की अनुमति मिलनी चाहिए, और प्रत्येक परियोजना निर्देशिका में एमएसएससीसीपीआरजेएससीसी क्रूफ्ट की पीढ़ी को भी खत्म करना चाहिए।