how to programatically uncheck the option "store only latest version property in VSS" for a project? - visual-sourcesafe

I have an issue in VSS 2005, there is a project in VSS, having multiple folders files in it, and most of the files around 2000 having their property "Store only latest version" is checked.
I want to change all those 2000 files property "Store only latest version" to unchecked, so that VSS retain all those files previous version.
can it be done through a single command to unchecked this option for all those files in project recursively?
Thanks

User the command line utility ss with properties command and the -L- (unset Retain only latest version) and -R (recursive) like below
ss properties -L- -R $/foo/*.*
From http://blogs.msdn.com/b/checkitout/archive/2005/01/20/357820.aspx
Note - for the command line utility to work you will need to set the SSDIR environment variable to point to your srcsafe.ini folder.
SET SSDIR=\\dirfoo\foo

Related

How to get clang format for Xcode 8?

After Xcode update to version 8. The very useful Alcatraz PlugIn Manager is locked out and superb utilities like clang-format, or highlight selected word occurrences, or resize the font by use of a shortcut are gone.
How can I reenable clang-format to format my current source code file on save with a template .clang-format in any parent directory of the source file?
You could create a shell script that is added to Xcode 8 as a behavior: Xcode > Behaviors > +(to create new one) > Run script: (select file here), add shortcut like Cmd+Shift+S.
The script asks Xcode to save the current document. Then it extracts its filepath and calls clang-format to format that file in-place. Clang-format has to be available e.g. by using brew as the package manager to download it and having its path published for command line access. As usual the style guide used by clang-format must have the name .clang-format and must be in any parent folder of the source file.
Here is the script:
#!/bin/bash
CDP=$(osascript -e '
tell application "Xcode"
activate
tell application "System Events" to keystroke "s" using {command down}
--wait for Xcode to remove edited flag from filename
delay 0.3
set last_word_in_main_window to (word -1 of (get name of window 1))
set current_document to document 1 whose name ends with last_word_in_main_window
set current_document_path to path of current_document
--CDP is assigned last set value: current_document_path
end tell ')
LOGPATH=$(dirname "$0")
LOGNAME=formatWithClangLog.txt
echo "Filepath: ${CDP}" > ${LOGPATH}/${LOGNAME}
sleep 0.6 ### during save Xcode stops listening for file changes
/usr/local/bin/clang-format -style=file -i -sort-includes ${CDP} >> ${LOGPATH}/${LOGNAME} 2>&1
# EOF
Please exchange the path /usr/local/bin to the one where your clang-format executable resides.
Happy coding!
The mapbox/XcodeClangFormat extension looks like a promising way to get clang format working with Xcode8.
Due to the limitations of source editor extensions, unfortunately you can only specify one .clang-format file for all your projects. "Format on save" also is not available.
Found a viable solution in this blog - code-beautifier-in-xcode
Basically, we can have clang-format running as a service by automator and invoke it through Xcode whenever we need to format the code. Refer the blog for more details.
Unfortunately your little script often does not update the formatted file in Xcode because it stops listening to file updates when saving. Increasing the sleep durations in the script does not make it more reliable and introduces a lot of waiting time for the common file-save & file-format action.
What I did in your situation was to get my mac backup and restore macOS and Xcode to the last version where all the productivity plugins from Alcatraz work fine again. This boosted my productivity.
It looks like Alcatraz plug-ins get be back to work in Xcode 8+ when unsigning them. Because I am not in the situation to try that, I can only point you to that resource:
Examine the header Installation on that github page ClangFormat-Xcode.

Faster way to compare changes made in Changeset for TFS Source Control

IF I have a large changeset and want to be able to compare all changes before checking them in, is there a faster way than manually clicking compare to latest on every file? I have something like 900 files I changed, and that seems veryinefficient. There has to be a way to open all files in compare and be able to click close or ignore on each file one by one.
Best way to compare large changeset vs existing code?
Try this:
Open a Visual Studio Command Prompt (All Programs | Visual studio | Visual Studio Tools | Developer Command Prompt
(this is just a normal command prompt but with some extra env variables set, and with the visual studio tools in your path).
use the cd command to switch directory to the root directory that your project is in on your local disk that you want to compare: example: cd \MyProjects\TheProject
execute this command:
tf folderdiff . $/The/Tfs/Folder/Path/To/Corresponding/ProjectDir/On/Server /recursive /view:different
(there is a space between the "folderdiff" and the ".", and another space between the "." and the $/ The "." just says "use the current local path (you should be sitting on it). Being on the current path also gives the TFS command the context that it needs so that it knows how to connect to your TFS server, and which team project and collection to use.

VS PostBuild Event - Copy file if it exists

Is there a simple way to copy a file in a post-build event for a Visual Studio project, but only if the file exists? (i.e. don't fail the build if the file doesn't exist)
I've tried some options using xcopy. But I feel so stupid - I can't seem to get my head around what switches I might need with xcopy.
Use "IF" command:
IF EXIST file.txt xcopy file.txt [destination_folder]\ /Y
Also without the IF EXIST but using the /U option of XCOPY
xcopy source_file_name dest_folder /u /y
If you prefer to use "Copy to Output Directory" in the Properties panel (provided by Visual Studio when you right-click on a project-file and select "Properties"), you can do so with a little bit of text-editing. This will work for all versions of Visual Studio that use MSBuild (i.e. Visual Studio 2010 and onward).
First, choose an appropriate value for "Copy to Output Directory", such as "Copy always" or "Copy if newer". Save your changes to the project (e.g. "Save all" from the "File" menu).
Then, edit the project file in a text editor, and inside the opening tag of the newly-added <CopyToOutputDirectory> element, add an attribute like Condition="Exists('$(MSBuildProjectDirectory)\FILENAME')", ,where FILENAME is the path of the file being copied (i.e. as referred to in the parent element).
The GUI won't edit this setting properly in the future (i.e. it'll display "Do not copy" as the value if the file doesn't exist), but at least it'll work.

How to configure Visual Studio to use Beyond Compare

I would like to configure Visual Studio to open Beyond Compare by default as the diff tool. How can I do this?
In Visual Studio, go to the Tools menu, select Options, expand Source Control, (In a TFS environment, click Visual Studio Team Foundation Server), and click on the Configure User Tools button.
Click the Add button.
Enter/select the following options for Compare:
Extension: .*
Operation: Compare
Command: C:\Program Files\Beyond Compare 3\BComp.exe (replace with the proper path for your machine, including version number)
Arguments: %1 %2 /title1=%6 /title2=%7
If using Beyond Compare Professional (3-way Merge):
Extension: .*
Operation: Merge
Command: C:\Program Files\Beyond Compare 3\BComp.exe (replace with the proper path for your machine, including version number)
Arguments: %1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9
If using Beyond Compare v3/v4 Standard or Beyond Compare v2 (2-way Merge):
Extension: .*
Operation: Merge
Command: C:\Program Files\Beyond Compare 3\BComp.exe (replace with the proper path for your machine, including version number)
Arguments: %1 %2 /savetarget=%4 /title1=%6 /title2=%7
If you use tabs in Beyond Compare
If you run Beyond Compare in tabbed mode, it can get confused when you diff or merge more than one set of files at a time from Visual Studio. To fix this, you can add the argument /solo to the end of the arguments; this ensures each comparison opens in a new window, working around the issue with tabs.
Visual Studio with Git for Windows
If you're using GIT as your source code management system instead of the (fairly dated) TFVC then Visual Studio doesn't have options to configure anything like this.
Instead it (rightly in my opinion) uses the GIT config file's setting. So if you already have GIT setup to use Beyond Compare or any other third party comparison software it will just pick this up and start using it.
If not then just set that up (see here for further and likely more up to date help). The relevant info for setting up Visual Studio with Beyond Compare 4 is:
Open Visual Studio.
Select Options from the Tools menu.
Select Plug-In Settings under the Source Control branch of the left-side tree control.
Select Microsoft Git Provider under Plug-In Settings on the right-hand pane.
Edit the global git config file (location is OS specific for windows it's %HOMEDRIVE%%HOMEPATH%/.gitconfig. See here for info) OR if you want it to be repo specifict then after starting a project in a Git repository, edit the config file in the .git folder in the project folder.
Change the config file to reflect the following changes:
[diff]
tool = bc4
[difftool "bc4"]
cmd = \"C:\\Program Files (x86)\\Beyond Compare 4\\BComp.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
tool = bc4
[mergetool "bc4"]
cmd = \"C:\\Program Files (x86)\\Beyond Compare 4\\BComp.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"
If 64bit installer is used, verify the name of the executable. Mine
was BCompare.exe
[diff]
tool = bc4
[difftool "bc4"]
cmd = \"C:\\Program Files\\Beyond Compare 4\\BCompare.exe\" \"$LOCAL\" \"$REMOTE\"
[merge]
tool = bc4
[mergetool "bc4"]
cmd = \"C:\\Program Files\\Beyond Compare 4\\BCompare.exe\" \"$REMOTE\" \"$LOCAL\" \"$BASE\" \"$MERGED\"
Issues: If you create a new project and get VS to create the git repo at
the same time it WILL add a load of overrides to the .git/config file
forcing it to use Visual Studio again (Thanks for that MS!).
SO either create the git repo via another means after the project has been setup
(like via SourceTree or the command line etc...) OR edit the .git/config file
(in the solution folder) and remove any overrides for the above settings.
Thanks to minnow in the comments for bringing my attention to it again.
Note: I keep coming across this but I am using VS with GIT and the
answers aren't correct and although some of the comments mention a URL
with the correct answer it's not clear and if I kept missing it I'm
sure others will so hopefully this will solve that issue.
If you are using the TFS, you can find the more information in diff/merge configuration in Team Foundation - common Command and Argument values
It shows how to configure the following tools:
WinDiff
DiffDoc (for Word files)
WinMerge
Beyond Compare
KDiff3
Araxis
Compare It!
SourceGear DiffMerge
Beyond Compare 3
TortoiseMerge
Visual SlickEdit
I got bored of doing this every 6 months when a new version of Visual Studio comes out, or I move PCs, or a new member joins the team. So, PowerShell:
# .Synopsys
# Sets up Beyond Compare professional as Diff tool for all instances of Visual Studio on this PC
# If you don't use TFS, change the sccProvider as appropriate
[CmdLetBinding()]
param(
$bcPath = 'C:\Program Files (x86)\Beyond Compare 3\BComp.exe',
$sccProvider = 'TeamFoundation'
)
$ErrorActionPreference = 'stop';
$baseKey = 'REGISTRY::\HKCU\Software\Microsoft\VisualStudio\*'
function SetRegKeyProperties($keyPath, [hashtable]$keyProps){
if(!(Test-Path $keyPath)){
Write-Verbose "Creating $keyPath"
# Force required here to recursively create registry path
[void] (new-item $keyPath -Type:Directory -Force);
}
foreach($prop in $keyProps.GetEnumerator()){
Set-ItemProperty -Path:$keyPath -Name:$prop.Key -Value:$prop.Value;
}
}
$configBases = dir $baseKey | ? { $_.PSChildName -match '^\d+\.\d$' }
foreach($item in $configBases){
Write-Host "Configuring $item"
$diffToolsKey = Join-Path $item.PSPath "$sccProvider\SourceControl\DiffTools"
SetRegKeyProperties (Join-path $diffToolsKey '.*\Compare') #{Command=$bcPath;Arguments='%1 %2 /title1=%6 /title2=%7'}
SetRegKeyProperties (Join-path $diffToolsKey '.*\Merge') #{Command=$bcPath;Arguments='%1 %2 %3 %4 /title1=%6 /title2=%7 /title3=%8 /title4=%9'}
}
Works on my machine. YMMV. No warranties, no refunds. VS doesn't appear to cache the key, so takes effect immediately.
In Visual Studio 2008 + , go to the
Tools menu --> select Options
In Options Window --> expand Source Control --> Select Subversion User
Tools --> Select Beyond Compare
and click OK button..
The answer posted by #schellack is perfect for most scenarios, but I wanted Beyond Compare to simulate the '2 Way merge with a result panel' view that Visual Studio uses in its own merge window.
This config hides the middle panel (which is unused in most cases AFAIK).
%1 %2 "" %4 /title1=%6 /title2=%7 /title3="" /title4=%9
With thanks to Morgen
I'm using VS 2017 with projects hosted with Git on visualstudio.com hosting (msdn)
The link above worked for me with the "GITHUB FOR WINDOWS" instructions.
http://www.scootersoftware.com/support.php?zz=kb_vcs#githubwindows
The config file was located where it indicated at "c:\users\username\.gitconfig" and I just changed the BC4's to BC3's for my situation and used the appropriate path:
C:/Program Files (x86)/Beyond Compare 3/bcomp.exe
VS2013 on 64-bit Windows 7 requires these settings:
Tools | Options | Source Control | Jazz Source Control
CHECK THE CHECKBOX Use an external compare tool ... (easy to miss this)
2-Way Compare
Location of Executable: C:\Program Files (x86)\Beyond Compare 3\BCompare.exe
3-Way Conflict Compare
Location of Executable: C:\Program Files (x86)\Beyond Compare 3\BCompare.exe
BComp.exe works in multiple-tabbed scenario as well, so there is no need to add /solo unless you really want separate windows for each file comparison. Tested/verified on Beyond Compare 3 and 4. Moral: use BComp.exe, not BCompare.exe, for VS external compare tool configuration.
I use BC3 for my git diff, but I'd also add vscode to the list of useful git diff tools. Some users prefer vscode over vs ide experience.
Using VS Code for Git Diff
git config --global diff.tool vscode
git config --global difftool.vscode.cmd "code --wait --diff $LOCAL $REMOTE"
Can't comment because my reputation score is low.
Here's a waybackmachine link to Fresky's link

Get all files checked out by a user using the Visual Source Safe command line application SS.exe

We currently use VSS 6, this is not going to change I am afraid.
I am attempting to write a script that will allow a user to quickly copy all files that they have checked out to another directory tree. In order to do this I need to get a list of all the files that the user has checked out, and the directory that the file is checked out to. This is easy enough to do using status search in the GUI. But I need a way of doing it from the command line utility ss.exe.
Two links that may be of use:
VSS CommandLine Commands
VSS CommandLine Options
To expand on Panos reply
ss.exe Status $/ -R -U<Username>
Will get you the files of a particular user.
From the command line:
cd C:\Program Files\Microsoft Visual SourceSafe
SET SSDIR=<path to folder containing srcsafe.ini>
ss Status $/ -R -U<username> > checked-out-by-username.txt
And then check the contents of checked-out-by-username.txt for your check-outs.
For example:
My srcsafe.ini was in C:\Program Files\Microsoft Visual SourceSafe\MasterDatabase. And my username was bpaetzke.
So, my command line looked like this:
cd C:\Program Files\Microsoft Visual SourceSafe
SET SSDIR=MasterDatabase
ss Status $/ -R -Ubpaetzke > checked-out-by-bpaetzke.txt
If you want to get all users' check-outs, remove the -U and give the output file a generic name.
Other command line info:
commands
options
I came here looking for the same thing but with Visual Source Safe version >= 8.0, the command doesn't seem to work for me, instead I found an easier way to search using menu:
View -> Search -> Status Search
There select the option to search by user and specify the user name
See here for the command line usage of Status command. The command
ss.exe Status $/ -R -U
shows every file in the system that is checked out by the current user.

Resources