I need to replace some identifiers in my solution, to avoid conflicts with external dependencies.
I used the Find and Replace dialog, setting the Entire solution as scope. It works, but it is too long.
One possibility could be:
forfiles /s /p path\to\solution /m *.cpp /C "sed -i 's/oldid/newid/g' #file"
Anyway, I have external include directories located in path\to\solution, which means writing the line above for every project directory (and of course including also *.h files).
Instead, VS GUI is smart enough to parse *.h and *.cpp files, excluding external dependencies.
Is there some (Visual Studio) CLI tool to list solution files, excluding external dependencies?
Related
So, I was hit with the Cryptowall 3.0 ransomware virus. After decryption I am still left with a large amount of DECRYPT_HELP files in .txt, .html, .png and Windows Shortcut formats.
I need a batch script to recursively find the files containing the name "DECRYPT_HELP" regardless of its' extension and move those files into a directory which I will delete.
I am a Linux guy, so I can't FIND and GREP my way through this. Any assistance would be appreciated.
You can find the files using
dir /s *decrypt_help*
dangerous command follows
del /s *decrypt_help*
will delete all of those files. use with extreme caution
I'm building an application that has quite a few files that need to be included in the destination directory. So far, there haven't been very many files so I would simply change the settings of each file individually to Copy to Output Directory :: Copy if newer. The problem now is that I'm adding files at an exponential rate.
Do any of you know how to make all of the files that are sub of the "Some_Directory" have the Copy to Output Directory :: Copy if newer set how I want it?
You cam use a post-build event.
Using following posts, I made a post event that does exactly what you want:
Copying files into the application folder at compile time
Copy to Output Directory copies folder structure but only want to copy files
Visual Studio adds .dll and .pdb to project after compiling
Now, you can easily edit Post-build events, go to your project settings and go to the Compile tab, now click the Build Events and put following line in the *Post-build event command line" text box:
xcopy "$(ProjectDir)Test\*.*" "$(TargetDir)Test\\" /E /I /F /Y
See this image:
In your case you will have to change "Test" by "some_directory" and that's all.
There is one caveat, however. This copies every file every time my project builds. The folder that is being copied is over 3MB (I'm developing quite a large project). This makes debugging take quite a long time because every time I do a build it has to move all of the content over. Is there a way to make it only copy over files that have been updated since the last build? This is why I was using the Copy if newer option.
You can add the /D parameter (you can look that up with xcopy /? in your command prompt).
/D:m-d-y Copies files changed on or after the specified date.
If no date is given, copies only those files whose
source time is newer than the destination time.
You can write your own custom Post-Build event (Select project -> Properties -> Build Events) with xcopy command. You can use $(solution) macro for your solution directory and specify relative path to your files.
I had the same issue, but the accepted answer didn't solve it. What worked for me was to enable deployment in Local.testsettings (under Solution Items).
I'm working on a visual studio solution with over 30 projects and multiple filters.
What is the easiest way to determine all the projects a file belongs too?
First, open a command shell window and create a list of all project files in a text file. For example, for C# projects (having the ending .csproj), run this command in the root folder of your solution:
dir /s /b *.csproj >projectlist.txt
Then, you can easily determine all projects containing a specific file by the command
findstr /f:projectlist.txt /m Name_Of_Your_File
Just a suggestion: you can avoid much trouble for the future if you make sure each project has it's own folder, and all files belonging to that project are in or below that folder.
Use AgentRansack or similar tool that allows searching text contained in a file.
Use the following settings:
File Name: *.csproj
Containing Text: YourCodeFile.cs
Look in: YourSolutionFolder
Run the search and you will get a list of all project files that are holders of the CS file.
I am trying to compile code, the makefile created using qmake.
When I run mingw32-make I get the following error:
cd bzip2-1.0.5\ && c:\QtSDK\Desktop\Qt\4.7.3\mingw\bin\qmake.exe c:\Documents an
d Settings\user\My Documents\Visual Studio 2010\Projects\meshlab\meshlab\meshla
b\src\external\bzip2-1.0.5\bzip2-1.0.5.pro -o Makefile
Cannot find file: c:\Documents.
Cannot find file: and.
Cannot find file: Settings\user\My.
Cannot find file: Documents\Visual.
Cannot find file: Studio.
Cannot find file: 2010\Projects\meshlab\meshlab\meshlab\src\external\bzip2-1.0.5
\bzip2-1.0.5.pro.
mingw32-make: *** [bzip2-1.0.5\Makefile] Error 2
By the error it appears that mingw32-make doesn't understand paths that have spaces in them. Is that true? Is there a way around it?
The common way to do it in Linux/UNIX is to escape each space with a backslash, like: /c/Documents\ and\ Settings/User However, this doesn't always work in MinGW.
So, use the short (8.3) name. You get the short name with the Windows (not MinGW) command for %I in (<PATH>) do #echo %~sI where <PATH> can be . (show current directory, like pwd), * (list files in current directory), a particular file path, etc.
Btw, to copy from the awful cmd.exe window, click the icon in the upper-left corner of the title bar, go to Properties, Options, and enable QuickEdit Mode. Then you can select text with your mouse. The Enter key (or menu>Edit>Copy) copies the text to the clipboard. The insert key (or menu>Edit>Paste) pastes it.
From the MinGW "Getting Started" guide:
MinGW may have problems with paths containing spaces, and if not, usually other programs used with MinGW will experience problems with such paths. Thus, we strongly recommend that you do not install MinGW in any location with spaces in the path name reference; i.e. you should avoid installing into any subdirectory of "Program Files" or "My Documents", or the like.
I suspect the same problems found in running executable files will also manifest itself with other files as well. You could try wrapping the whole thing (file specification) inside double quotes and this may work but Windows is sometimes not as logical as UNIX-based shells in this area.
Spaces in file names are evil anyway :-)
Not sure if this helpful or not (in fear of being downvoted), but I created a semantic link in order to avoid paths with spaces. Not sure if it will solve the problem since in my scenario it displayed a different error after I used the semantic link relating to pthreads which I still haven't been able to fix.
Creating semantic link using the command prompt:
mklink /j "C:\newshortcut" "C:\Program Files\Directory with spaces"
Then on the command you want to run, you use C:\newshortcut
Sorry for necroing this, but I had a similar problem and I was able to fix it using cygpath.
For my case I was trying to make an environment variable to visual studio:
export DEVENV="/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com
echo $DEVENV
$DEVENV $1 /build "Release|win64"
Which would result in:
/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com
-bash: /c/Program: No such file or directory
The solution was to use cygpath -w to convert the path with spaces into an 8.3 filename:
export DEVENV=$(cygpath -w -s "/c/Program Files (x86)/Microsoft Visual Studio/2019/Community/Common7/IDE/devenv.com")
echo $DEVENV
$DEVENV $1 /build "Release|win64"
Which results in:
C:\PROGRA~2\MICROS~1\2019\COMMUN~1\Common7\IDE\devenv.com
and no error. Hopefully this helps future travellers.
I'm working on some driver development and using Microsoft's build.exe tool from the WDK 6001 (Vista). I'd like to be able to clean up all the object and intermediate files it spews out on every iteration.
So far, I've found "build.exe -0 -c" works relatively well, by simply deleting all the .obj files, but none of the .sbr files or directories it created. I'd really like to avoid writing a makefile as another makefile would be hard to integrate into the build system.
How can I do this?
Have you though of a scripting language to to a recursive delete. We use Nant for our build system, and that has this type of thing built in.
A more windows answer might be to use powershell which you should be able to call from your makefile.
Or you could just revert to DOS commands. Thus
dir /S *.sbr
Shows me all my nested sbr files, and then
del /S *.sbr
deletes then all. And can be shown to have worked via the dir command again.