How to execute process before build multiple projects in a solution - c++

I'm using VS2010 on Windows 7 Ultimate x64.
I want to build multi-project in one solution automatically.
For example : )
Solution StormSolution contains 4 projects.
1 : Storm_Module1 (output file extension : dll)
2 : Storm_Module2 (output file extension : dll)
3 : CombineModule12 (output file extension : dat)
4 : ConvertModule2CFGFile (output file extension : cfg)
Step 1,2 : A result of Storm_Module1 and Storm_Module2 are Standard Windows DLL.
Step 3 : A result of CombineModule12 is open Storm_Module1.dll and Storm_Module2.dll to make "combined.dat" file, like cmd.exe /c copy /b storm_module1.dll + storm_module2.dll combined.dat command.
Step 3-1 : Then, make combined.dat file into encrypted_combined.dat file with encryption_tool.
Step 4 : Open "encrypted_combined.dat" file and make it into own specified cfg file.
The problem occurs on Step 4. I can't build solution storm automatically.
Because I've to make "combined.dat" result of Step3 into "encrypted_combined.dat" with encryption_tool.
So, if I build Storm solution without any action, ConvertModule2CFGFile project can not open latest updated encrypted_combined.dat.
How can I execute encryption tool before on Step4.
Encryption tool can be executed with parameters.
ex:) cmd.exe /c "encryption tool.exe -mode_crypt combined.dat -output encrypted_combined.dat.
Is it impossible to execute process before build project?

In Visual Studio you can create Post-Build Events which can execute a batch file. Use that to combine your two DLLs.
To make your projects build in the correct order, adjust Build Dependencies and Build Order in your Solution/Projects.

Consider writing a batch file for Visual Studio Command Prompt - it will enable you to build solutions 1 & 2 first, then you can perform any operation on files you like and call your encryption tool easily, and then build the last solution.
This thread should get you started:
How to create a Batch File for Visual Studio Command Prompt

Related

How to attach a process to the current debugger programmatically?

I have 2 projects in the solution that compile to A.exe and B.exe
A will start B and connect to it through a named pipe. I want to test the connection between them so I'd like to attach to both at the same time. Doing that manually every time is very tedious and inconvenient, especially when B will close after a timeout if it doesn't receive any data from A. Therefore I tried this
if (IsDebuggerPresent())
DebugActiveProcess(processId);
However it seems B is attached to A's debugger instead of Visual Studio's. So how can I attach B to VS debugger automatically?
I have windbg at hand for debugging crash dumps so it may also be a solution, as long as it can be done without multiple user interactions
Attach to a process B programatically
Method 1: Using VS
Open B.vcxproj and not your solution (.sln containning projects A and B)
Put your breakpoints
Run this dos command from your project A via system() (or other variant):
devenv /nosplash /run "G:\Logiciels\B\B.vcxproj" /nosplash /debugexe
devenv is a command in your VS path. In my case it in:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC
When you run this command, B project is opened and break point reached.
Method 2: Using Windbg
Just call this command:
windbg -p ProcessID
Attach to a process B graphically
Open your B project in another instance, and attach to it like this :
And select your B.exe:

TFS PowerShell task not producing output when used with devenv

I can't use MSBuild to compile SSIS projects as it's not supported yet. Hence,
I'm trying to use VS2017 devenv.exe to compile SSIS projects in my TFS (2017) task via PowerShell. I don't see any errors but neither I see the compiled output from dtproj files i.e. dtsx or ispac.
However, if I run the same powershell command manually on the build agent machine then it works fine and produces the output files. This is the command I'm trying:
$VsIdeExe = 'C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\devenv.exe'
$BuildConfiguration = 'Development'
$PackageStagingLogsDirectory = "C:\temp\logs"
& "$VsIdeExe" "C:\temp\Source\SSIS\MyData.sln" /build "$BuildConfiguration" `
/log "$PackageStagingLogsDirectory\MyData.ide.log" `
/out "$PackageStagingLogsDirectory\MyData.sln.log"
What am I missing here?
I found an alternative and it works. So, instead of using PowerShell task, I used Command line task and it works like a charm! I don't know how the mechanics are different between these 2 tasks but my use case sufficed.
Thanks!

OpenSSL build odd behaviour

Its kinda an odd story. I'm trying to build the openssl library. Well, it is not the first time I'm doing it and until now it was fine. however, I've desided to add a build configuration to TeamCity (actually the problem has nothing to do with TeamCity)to build all my third parties libraries on-demand. So, I created a step with common set of openssl build commands:
perl Configure VC-WIN64A
ms\do_win64a.bat
nmake /d /f ms\ntdll.mak
... and the build failed while assembling the very first asm file. So I ran same commands in VS2012 x64 command prompt and the build succedeed, as expected. It took a while untill I figured out that the problem is in output redirection. Teamcity redirects output from build step to the teamcity build log, so did I by adding ">1.txt" to "nmake /d /f ms\ntdll.mak" command, and the build failed. I would say it is somewhat unexpected reason for build to fail.
So far, I've tried:
Building the same from VS2010 command prompt with redirection,
failed.
Building the same from VS2010 command prompt without
redirection, succeded.
Building the same from VS2010/VS2012 command
prompt with redirection to file and forcing redirection to CON (nmake
/d /f ms\ntdll.mak >CON >1.txt) failed.
Googling for "nmake problems
when console output is redirected" - nothing
Googling for "openssl
build problems when console output is redirected" - nothing
My setup
- Win2008R2, virtual machine.
- VS2010, latest updates
- VS2012, Update 1
Actual error:
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\BIN\amd64\ml64.EXE"' : return code '0x1'
ml64.exe complains about the asm file stating it should end with "END" statement. It does, but...
Any ideas?
Ok, since the problem is in perl and writing files to stdout and then redirecting it you have to change following files to build x64 version:
crypto\aes\asm\aes-x86_64.pl
crypto\bn\asm\modexp512-x86_64.pl
crypto\bn\asm\x86_64-gf2m.pl
crypto\bn\asm\x86_64-mont.pl
crypto\bn\asm\x86_64-mont5.pl
crypto\md5\asm\md5-x86_64.pl
crypto\modes\asm\ghash-x86_64.pl
crypto\rc4\asm\rc4-md5-x86_64.pl
crypto\rc4\asm\rc4-x86_64.pl
crypto\sha\asm\sha1-x86_64.pl
crypto\sha\asm\sha512-x86_64.pl
crypto\whrlpool\asm\wp-x86_64.pl
crypto\x86_64cpuid.pl
engines\asm\e_padlock-x86_64.pl
you have to open these files and change all "open STDOUT "whateverfile"" to something like "open my $asmfile "whaeverfile"", then take care of string concatenation (only in x86_64cpuid.pl) and then print it to the file instead of STDOUT, something like "print $code" to "print $asm $code"
and of course, dont forget to close the file, in another words change the "close STDOUT" to "close $asmfile"
Obviously when building target other than x64 one will have to change another set of files.
Will try to communicate it to openssl maintainer.

failed pre-build event in visual studio 2010 cancels build

I have a python script which runs and generates a version-file. I use the following as a pre-build event for my project:
call python version.py
this works fine given that I have python installed and the file can be found. However, for users that don't, it throws an error and cancels the build.
Is there a way to make it so the visual studio just silently ignores the build event if the python-command is not found or the python-file is not found?
One option would be to wrap the call to python in a .bat file which will exit with 0 if python is not found, and replace the pre-build step with calling this .bat file.
An example of such a test could be:
python --version >nul
if errorlevel 1 exit 0

Eclipse CDT 4.2 debug remote external program

I'd like to debug to debug a remote application with GDB.
My target system is a FreeBSD 8.3 box with gdbserver running. The application has been compiled successfully on that box. My Eclipse CDT 4.2 runs on Windows 7 with recent MinGW installed.
This is an external program I'd like to debug. It is neither written by me nor I do have it as a library. I do not intend to write my own program. In this case it is Subversion 1.8.0-dev which I want to debug.
I have created a simple C project, attached the source of Subversion. Created a remote debug config and attached the sources to the running thread in gdbserver.
Now, eclipse enters the main function of Subversion but when I set a breakpoint in another attached source file, Eclipse says: No source file named ra_loader.c or it simply says "No source available".
Then It simply exists the application.
What am I missing here?
Try the suggestion made on this thread
Quote :
1) run a debug session and open the gdb console inside Eclipse
('Console' tab -> 'Display Selected Console' button -> choose the one
ending with 'gdb')
2) use command 'pwd' in the console to print
gdb's current working dir
3) use command 'info line main' to get
the source file where gdb expect to find of my "int main(...)"
function
4) concatenate the result of step 2 with result of step
3 (which should be a relative path) to see if it matches the
correct source file I want
5) use the 'cd' command in gdb (to
change the current working dir) till I get the correct match in
step 4
Knowing the initial working directory (2) and the correct working directory (5) for gdb , I had 2 options: 1) Use gdb's 'cd'
command every time I launch a debug session (I could setup a
.gdbinit file in the gdb initial working directory to do this
automatically) or 2) Setup the 'Source' tab, in 'Debug
Configurations', to make Eclipse use paths that match with gdb's
initial working dir ('Project - Path Relative to Source Folders'
worked for me)