TFS: Check if local file is latest version from within script - tfs

Ref: Visual Studio Team Foundation Server 2015:
How do i check from within a batch- or Powershell-script for a given file under TFS source control, if a local file is or is not equal to the latest version on the server?

You can use tf.exe, which comes with Visual Studio. Here are some different options using PowerShell. This could also be written in batch with a few changes.
Assume the following:
# Change directory to the folder containing your file.
Set-Location "D:\MyProjects\Project1\Logic"
# File to evaluate
$file = "Program.cs"
# Using the Visual Studio 2015 Common Tools System Variable to find tf.exe
$tfExe = "$env:VS140COMNTOOLS\..\IDE\TF.exe"
1: Use get /preview, which will preview if it can get a newer version.
& cmd /c "`"$tfExe`" get $file /preview"
Result if latest:
All files are up to date.
Result if not latest:
D:\MyProjects\Project1\Logic:
Replacing Program.cs
Get Documentation Link
2: Use difference /format:Brief with status, which will tell you if there are differences locally, but no pending changes
& cmd /c "`"$tfExe`" difference $file /format:Brief"
& cmd /c "`"$tfExe`" status $file"
Result if latest:
Comparing local to latest: D:\MyProjects\Project1\Logic\Program.cs
There are no pending changes.
Result if not latest:
Comparing local to latest: D:\MyProjects\Project1\Logic\Program.cs
Program.cs: files differ
There are no pending changes.
Difference Documentation Link
Status Documentation Link
3: Use info, which will show the local changeset and the server changeset, and you can see if they're different.
& cmd /c "`"$tfExe`" info $file"
Result:
Local information:
Local path : D:\MyProjects\Project1\Logic\Program.cs
Server path: $/MyProjects/Project1/Logic/Program.cs
Changeset : 2842
Change : none
Type : file
Server information:
Server path : $/MyProjects/Project1/Logic/Program.cs
Changeset : 2845
Deletion ID : 0
Lock : none
Lock owner :
Last modified: Friday, December 15, 2017 4:32:57 PM
Type : file
File type : utf-8
Size : 2835
Info/Properties Documentation Link
There is also LocalVersions, which will tell you the local changeset of your file, and History which will show all changesets of the file.

Related

Get Microsoft Edge Browser Version using registry or command line

How can i get microsoft edge browser version using registry or command line?
I don't want to take it from UI.
For Microsoft Edge Legacy, you can get the version from PowerShell with Get-AppxPackage:
> (Get-AppxPackage Microsoft.MicrosoftEdge).Version
44.18214.1000.0
If you want to call this from cmd.exe, you can just call Powershell:
> powershell.exe "(Get-AppxPackage Microsoft.MicrosoftEdge).Version"
44.18214.1000.0
In Windows
The first of all, you need to get the path of the .exe file of the application.
use Get-Item
It is just like Get-AppxPackage. And get the version by adding .VersionInfo.
> (Get-Item "C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe").VersionInfo
ProductVersion FileVersion FileName
-------------- ----------- --------
85.0.564.63 85.0.564.63 C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe
use wmic
wmic can get the information of the application. And we set the name key for which application you want to check.
> wmic datafile where 'name="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"'
AccessMask Archive Caption Compressed CompressionMethod CreationClassName CreationDate CSCreationClassName CSName Description Drive EightDotThreeFileName Encrypted EncryptionMethod Extension FileName FileSize FileType FSCreationClassName FSName Hidden InstallDate InUseCount LastAccessed LastModified Manufacturer Name Path Readable Status System Version Writeable
1179817 TRUE C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe FALSE CIM_LogicalFile 20200924185451.733609+480 Win32_ComputerSystem DESKTOP-QCUDFJL C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe c: c:\program files (x86)\microsoft\edge\application\msedge.exe FALSE exe msedge 2882448 Application Win32_FileSystem NTFS FALSE 20200924185451.733609+480 20200928200140.091076+480 20200923164851.469016+480 Microsoft Corporation C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe \program files (x86)\microsoft\edge\application\ TRUE OK FALSE 85.0.564.63 TRUE
And then, filter the result by adding get {key} at the end of command.
> wmic datafile where 'name="C:\\Program Files (x86)\\Microsoft\\Edge\\Application\\msedge.exe"' get version
Version
85.0.564.63
In MacOS
use --version
The application is executed from /Applications/"Microsoft Edge.app"/Contents/MacOS/"Microsoft Edge. Therefor, we can command like the bottom.
$ /Applications/"Microsoft Edge.app"/Contents/MacOS/"Microsoft Edge" --version
Microsoft Edge 85.0.564.63
The older answers to this question seem to address Edge Legacy to the exclusion of Edge Chromium (which is now standard). Adding this answer to more fully outline current options targeting Edge Chromium, specifically.
Windows via Registry
For Windows systems, reading the Edge version from the registry is probably your best bet, since it's consistent even when the installation path varies. Some command-line for reading the installed version of Edge Chromium from the registry. There are a few options for that.
Using Powershell:
(Get-ItemProperty -Path HKCU:\Software\Microsoft\Edge\BLBeacon -Name version).version
Using Powershell and Windows Script Host:
(New-Object -ComObject WScript.Shell).RegRead("HKCU\Software\Microsoft\Edge\BLBeacon\version")
Using Reg Query:
reg query HKCU\Software\Microsoft\Edge\BLBeacon /v version
Windows via Executable
If you have more than one instance of Edge installed (for example, an Edge Dev Channel build) and you want to get the version of a specific installation, you can access the VersionInfo metadata of the Edge executable.
Using Powershell:
(Get-Item "C:\Program Files (x86)\Microsoft\Edge Dev\Application\msedge.exe").VersionInfo.FileVersion
Using the WMIC tool:
(Note that escaping is required when translating the EXE path into the WMI query)
wmic datafile where 'name="C:\\Program Files (x86)\\Microsoft\\Edge Dev\\Application\\msedge.exe"' get Version
Non-Windows via App Binary
For non-Windows installations, running the binary from your shell with the --version flag seems to be the best bet. Your path may vary.
Ubuntu example:
/usr/bin/microsoft-edge --version
Mac OSX example:
/Applications/Microsoft\ Edge.app/Contents/MacOS/Microsoft\ Edge --version
Via Package Managers:
Especially on Linux installations, where Edge is likely to have been installed using a standard package manager, version querying via package management is also a solid option.
Note that this option does only apply if the Edge installation is under package management, which is pretty uncommon in non-Linux userland.
Using apt (Ubuntu):
apt list microsoft-edge
Using Homebrew (Mac OSX):
brew info microsoft-edge
Using Chocolatey (Windows):
choco list -l microsoft-edge
Run the following command:
REG QUERY HKEY_CLASSES_root\AppX3xxs313wwkfjhythsb8q46xdsq8d2cvv\Application /v ApplicationName
Example output:
HKEY_CLASSES_ROOT\AppX3xxs313wwkfjhythsb8q46xdsq8d2cvv\Application
ApplicationName REG_SZ #{Microsoft.MicrosoftEdge_40.15063.674.0_neutral__8wekyb3d8bbwe?ms-resource://Microsoft
.MicrosoftEdge/Resources/AppName}
Now you just need to extract the version, e.g. the 40.15063.674.0.

Not able to run .vbs file from jenkins which is having excel script

I’m new to Jenkins and now I'm doing basic level of execution. And I need your help resolve my issue. Issue Description: I’m trying to run the .VBS file by using jenkins and getting below error:
C:\Users\Amar\Desktop\Test_Sample.vbs(3, 2) Microsoft Excel: Microsoft Excel cannot access the file ‘C:\Users\Amar\Desktop\New.xlsx’.
There are several possible reasons:
The file name or path does not exist.
The file is being used by another program.
The workbook you are trying to save has the same name as a currently
open workbook.
I have not opened any excel file and path also correct.
please find below batch command : CScript “C:\Users\Amar\Desktop\Test_Sample.vbs”
And in Test_Sample.vbs file having:
Dim ExcelObj, WbookObj, mysheet
Set ExcelObj= CreateObject("excel.application")
Set WbookObj= ExcelObj.workbooks.open("C:\Users\Amar\Desktop\New.xlsx")
Set mysheet= ExcelObj.ActiveWorkbook.Worksheets("Sheet1")
ExcelObj.Visible = False
ExcelRowCount = mysheet.UsedRange.Rows.Count
For Iterator = 2 To ExcelRowCount
ModuleName = Ucase(Trim(mysheet.Cells(Iterator,1)))
ExecutionFlag = Ucase(Trim(mysheet.Cells(Iterator,2)))
if (moduleName="Raj") Then
Set qtApp = CreateObject("QuickTest.Application")
If qtApp.launched True then
qtApp.Launch
End If
qtApp.Visible = True
qtApp.Open "F:\Jenkins_Jobs\OnCall_Sanity_Automation\DriverScript\Sample", False
Set QTPTest=qtApp.Test
QTPTest.Run 'Run the Test QTPTest.Close
qtApp.quit
Set qtApp = Nothing
else
MsgBox "Name not exists"
End If
Next
Please help me to resolve the issue.
Thanks, Amar
Update
Console Output:
Building in workspace C:\Program Files
(x86)\Jenkins\workspace\Excel_Test [Excel]
$ cmd /c call C:\WINDOWS\TEMP\jenkin02.bat (C:\Program Files
(x86)\Jenkins\workspace\Excel_Test>CScript )
C:\Users\Admin\Desktop\Test_Sample.vbs"
C:\Users\Admin\Desktop\Test_Sample.vbs(3, 2) Microsoft Excel:
Microsoft Excel cannot access the file
C:\Users\Admin\Desktop\New.xlsx. There are several possible reasons:
** The file name or path does not exist.** The file is being used by another program. The workbook you are trying to save has the same
name as a currently open workbook.
If you are working on 64-bit Windows Operating System.
Then go to
C:\Windows\SysWOW64\config\systemProfile
Above Folder and create an empty Folder, and name it "Desktop" inside "systemProfile".
For doing this, you need system admin access
After creating the folder as mentioned, then run your build in Jenkins.
Run the jenkins job in command prompt on a slave,it will work!
Set Full control permissions for below path "Desktop" directory
"C:\Windows\SysWOW64\config\systemprofile\Desktop " (for 64 bit Windows) or "C:\Windows\System32\config\systemprofile\Desktop " (for 32 bit Windows)
If Desktop directory in present please create and give Full control permissions

Where are latex files when I compile a package

I am wondering why I cannot find the latex source for the manual of the
package when it is compiled/check .
I use Rstudio to compile/check a package. There is an option 'clean up output after successfully R CMD check' that is not checked. I also use '--no-clean --with-keep.source' in R CMD check.
When I press on CHECK some files are generated in the same folder as the source files. One of them is NAME-OF-THE-PACKAGE-manual. The first line of this file is:
This is pdfTeX, Version 3.1415926-2.5-1.40.14 (MiKTeX 2.9 64-bit) (preloaded format=pdflatex 2015.5.5) 27 MAY 2015 13:00
entering extended mode
**C:/Users/USER_NAME/AppData/Local/Temp/Rtmpq6HXud/Rd2pdf523830b237c3/Rd2.tex
that means there is a Rd2.tex latex file but when I check the path, it does not exist.
In short: I am looking for the .tex source of the manual.
R CMD Check is just trying to make sure it can build a reasonable PDF. If you want to make your own copy of the manual in TeX or PDF formats, there are separate R CMD entries that do just that: try R CMD Rdconv or R CMD Rd2pdf.
Reference:
https://stat.ethz.ch/R-manual/R-devel/library/base/html/RdUtils.html

TFS how to get back a locally deleted file

Environment: Ubuntu 14.04, TFS command line (TEE-CLC 12.0.1).
I made changes in a file from my local workspace. However, to discard my changes, I simply deleted the file with the hope that "tf get" will get me the latest copy. However, I am getting an error instead:
$ tf get
Conflict settings.cpp - Unable to perform the get operation because
you have a conflicting edit.
The merge can't complete because the existing file isn't available:
I figured I could force-update:
$ tf get settings.cpp /force
An argument error occurred: Unable to determine the workspace.
You may be able to correct this by running
'tf workspaces -collection:TeamProjectCollectionUrl'.
I would appreciate your help in understanding how to get back my file. Regards.
You are trying to specify the force option, but you are using Windows-style arguments. On Unix, files are separated with a / character, so you cannot use it as an argument, or it would be ambiguous whether you were specifying /force the option, or /force the file named force in your / directory.
Try:
tf get -force settings.cpp
Of course, if you are using a Local Workspace, or if you have pended the change, then you should just undo the change:
tf undo settings.cpp

Setting up Rails project on TeamCity hosted on a Windows server

I'm setting up my first Ruby project on Team City, which is hosted on a Windows Server, but I'm having a problem. Now, because the server may not have the required gems installed, I've added a command line build step:
bundle install
Now I thought this would be enough, but apparently bundle is not recognized as an internal or external command. Except, if I RDP into the server, if I run bundle install from anywhere, it is fine, and just notifies me that no gemfile was found.
Any ideas on if I've missed a step, or I'm going about this the wrong way?
Most likely this is a problem with TeamCity not finding the path to ruby executables.
You can address this by overriding the value to the PATH environment variable in your build configuration in the Build Parameters section.
env.PATH=/path/to/ruby;%env.PATH%
See this answer for the proper links to documentation, etc.
EDIT #1
I noticed when updating one of my configurations that TeamCity is supposed to take care of appending values so you DO NOT need to set path equal to itself. The post mentioned above is a workaround for a bug where TeamCity was overwriting the values, but that has been corrected. See the help at the mouse-over for more information:
EDIT #2
I tested edit #1 and found that is not the case. You do need to
create an environment variable env.Path
and set it's value to itself plus your new path; in my example, C:\Program Files\MySQL\MySQL Server 5.6\bin\;%env.Path%
you do NOT need to say env.Path=... as listed above; that is what the configuration file will look like.
I tested this out by doing the following:
Created a new project with no repository
Added a command line build step to `echo %env.Path%
Added a command step to call MySql mysql --help This will fail if it cannot find MySql
I then ran it for each of the following settings for the env.Path variable:
Not added / changed; TeamCity reports out the environment variable for the build agent as is.
Added as just C:\Program Files\MySQL\MySQL Server 5.6\bin\. TeamCity reports out only that entry.
Added as C:\Program Files\MySQL\MySQL Server 5.6\bin\;%env.Path%. TeamCity prepends C:\Program Files\MySQL\MySQL Server 5.6\bin\ to the build agent's values shown in #1. The result is what we want, #1 + #2

Resources