I have next pre build event:
cmd /C mklink /D /J "$(ProjectDir)SomeDir" "$(ProjectDir)"
This is expanded in(copied from MSBuild output):
cmd /C mklink /D /J "C:\Dir-1\Dir-2\other-dirs-here\SomeDir" "C:\Dir-1\Dir-2\other-dirs-here\"
When running the build with this build event the symbolic link is not created, but when I copy exactly the expanded output of Visual Studio in command line the link is created.
Do you know why?
EDIT: I have administrator rights on the computer. Both Visual Studio and Command Prompt have "Administrator" on top
Found the problem - the previous command in the build event was:
$(ANDROID_HOME)/tools/android.bat update project my-project-settings
and for some weird reasons prevented all commands after it to run...
Related
I am getting weird behavior of "Developer Command Prompt for VS 2017" command line tool. Normally in previous versions of visual studio this script (VsDevCmd.bat) was not messing current directory from where you run it. Now it seems to change it. One simple workflow would be just to start the shortcut "Developer Command Prompt for VS 2017" and it doesn't honor the "Start in" directory:
By any chance anyone seen this issue? It really bugs me because I used to have a shortcut with it and start CMD in my source directory, use TFS/msbuild commands afterwards.
You can set the VSCMD_START_DIR environment variable to have vsdevcmd.bat change to that directory when it finishes. Otherwise it will check if you have a %USERPROFILE%\source directory and change to that (which is what you see).
You can change the "Target" for the "Developer Command Prompt for VS 2017" to something like the following to have change to a particular directory:
%comspec% /k "set VSCMD_START_DIR=C:\temp && "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat""
Note that the path to vsdevcmd.bat needs to be put in an additional set of double quotes.
Alternatively, rename or remove the %USERPROFILE%\source directory (Note that this seems to be some kind of new "standard" directory for sources), that will make vsdevcmd.bat honor the "Start In"-value (i.e. "current directory").
:: Some rocket scientist in Redmond made the VS15 VsDevCmd.bat change the cwd; the pushd/popd fixes that.
pushd %CD%
call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\Tools\VsDevCmd.bat"
popd
"C:\Program Files (x86)\CruiseControl.NET\server\ccnet.exe" %*
vsdevcmd_end.bat, REM out the line:
cd /d "%USERPROFILE%\Source"
#REM Set the current directory that users will be set after the script completes
#REM in the following order:
#REM 1. [VSCMD_START_DIR] will be used if specified in the user environment
#REM 2. [USERPROFILE]\source if it exists
#REM 3. current directory
if "%VSCMD_START_DIR%" NEQ "" (
cd /d "%VSCMD_START_DIR%"
) else (
if EXIST "%USERPROFILE%\Source" (
cd /d "%USERPROFILE%\Source"
)
)
If I see your quastion in right way that I'm used to work with EntityFramework Core with the help of CMD or PowerShell. For this you should right-click In the Solution Explorer panel then in the context menu, click Open Folder in File Explorer. In the address bar of the file explorer type cmd or powershell, you will start the command line from the project folder.
I am using Visual Studio 2013 Ultimate Update 5
I was using successfully vsDiffMerge.exe as the diff and merge tool both in Sourcetree as well as from command line (using the /t and the /m options)
All of a sudden (only thing I can note is Windows update "KB4015217") the vsDiffMerge stopped working in case of merge (the /m option) and instead it started behaving as if it is an automated merge followed by a diff !!
The command line syntax
"C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\vsDiffMerge.exe" "$fremote" "$flocal" "$fbase" "$fmerge" /m /t
would generate a strange window such as this
Output of the vsDiffMerge.exe with the /m /t option, same if we use only /m
We have tried all the tricks in the book: devenv /resetuserdata , reset all settings from import/export, reset Window layout, and doing a complete VS Repair
Any suggestion how to go about solving this problem ?
We ended moving to P4Merge to get a working tool for this.
I will close this thread.
Since I cannot locate Native Tools CMD under the Tools menu, I try to manually add it in External Tools. Few questions:
Regardless of what I choose for Command (ARM, x86 or x64 etc.), Command is always C:\Windows\System32\cmd.exe. Why the different CMDs end up having the same path to the native System32's CMD?
Referring to this answer, I should insert /k "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Tools\VsDevCmd.bat" to the arguments - what is the /k and what is the bat for this argument? Why do I need to pass a path as an argument to the command prompt?
What is Initial Directory?
Why the different CMDs end up having the same path to the native System32's CMD?
The VS2015* CMDs are just cmd.exe with some environment variables already set up for you. so for example instead of typing "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe" to run InstallUtil.exe you will just type InstallUtil and it will work. if you didn't set up the environment variables you will get an error message saying that 'installutil' is not recognized as an internal or external command, operable program or batch file.
what is the /k and what is the bat for this argument? Why do I need to pass a path as an argument to the command prompt?
/k is a parameter for cmd.exe and what it does is run the commands specified by the string that follows (in this case it will execute what's inside "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat" and will carry out).
What is Initial Directory?
Initial directory is used to specify the working directory that your cmd.exe instance will start in
So in the end you'll have something like this for Visual Studio 2015:
The "arguments" for VS2015 is :
/k "C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat"
I took a look at my start menu and right clicked on Developer Command Prompt for VS2015. Copied target %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsDevCmd.bat""
MSBuild Command Prompt for VS2015
Copied target %comspec% /k ""C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\VsMSBuildCmd.bat""
https://connect.microsoft.com/VisualStudio/feedback/details/747807/vs2012-x64-native-tools-command-prompt
#echo off
echo copy masterDB file from one directory to another one
copy "C:\dir\dbfile" "C:\dir1\dbfile"
cd c:\lvsdir
call lvsrun.bat
timeout /t 180
start %comspec% /k ""C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat"" x86
cd C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE
MSTest /testcontainer: C:\testdir\test.dll
I want to do via a batch file to copy a db file from one directory to another one(which executes correct), then should start lvsrun.bat file, which should start lvs server,
and then to open visual studio command prompt in a new window, change directory in opened command prompt to test directory and run test file. Problem occurs when i call lvsrun.bat, and it stucks there. New vs command prompt can't be opened. And having problem with changing directory in opened vs command prompt and run test file. Code above doesn't really work
You've asked two questions here. You should split them up and ask them as two separate SO questions.
Q1. Why is my batch file never getting past call lvsrun.bat?
A1. Because call will not return until the batch file it is calling has exited. If you want to launch lvsrun.bat and continue execution immediately, use start.
copy "C:\dir\dbfile" "C:\dir1\dbfile"
cd c:\lvsdir
start "" "%comspec%" /k lvsrun.bat
Q2. Why doesn't the new command window I launch run my test file?
A2. Your batch file will only control its command window. If you launch another command window, that one is on its own, you can't "send" commands to it. But you could instead run the test in the current window rather than launching another:
:: Use "call" here to run vcvarsall.bat to set up the environment in this process
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
cd C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE
MSTest /testcontainer: C:\testdir\test.dll
Or you could make a second batch file just for running the test. For example, let's call it runtest.bat, and give it those exact same lines:
call "C:\Program Files\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86
cd C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE
MSTest /testcontainer: C:\testdir\test.dll
which would then get called from your original batch file either synchronously:
call runtest.bat
or asynchronously:
start "" "%comspec%" /c runtest.bat
I've converted an old Visual C++ 6.0 project to a new Visual C++ 2010 one. It functions but I have a problem with the post build event which I took from the old project. It registered the target file (an .ocx) on the computer:
copy $(ProjDir)\PDFXChange\dll.Debug\*.* $(TargetDir)
regsvr32 /s /c "$(TargetPath)"
echo regsvr32 exec. time > "$(OutDir)\regsvr32.trg"
In my new solution it doesn't work. I've also tested it in single commands: of the three commands (copy, regsvr32 and echo) only the last one could be executed. What could be my error.
Error:
error MSB3073: The command "copy \PDFXChange\dll.Debug\*.* C:\_tests_\ocx2010\Debug\
regsvr32 /s /c "C:\_tests_\ocx2010\.\Debug\LayoutBox.dll"
echo regsvr32 exec. time > ".\Debug\\regsvr32.trg"
:VCEnd" exited with code 3. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\Microsoft.CppCommon.targets
COPY and REGSVR32 seem not to work.
The problem was in the name of the macro $(ProjDir). In Visual C++ 2010 it's $(ProjectDir)
$(ProjDir) -> $(Proj ect Dir)
Some macros altered their names (after so many years)!
The command copy \PDFXChange\dll.Debug*.* C:tests\ocx2010\Debug should copy some DLLs into the folder where the next command regsvr32 /s /c "C:tests\ocx2010.\Debug\LayoutBox.dll tried to register the target file. It couldn't find any DLLs there, so it quit with the error message.
Mismatch between
Project->Properties->Configuration Properties->General->Output Directory
and
Project->Properties->Configuration->Linker->Output File
I made the former like so...
$(SolutionDir)$(PlatformTarget)$(Configuration)\
and in the linker like so..
$(SolutionDir)$(PlatformTarget)$(Configuration)$(ProjectName).dll
and it solved the problem