How to run a script\executable before start debugging in VS2015? - c++

I need to run a code generator before starting compilation\execution of my code in Visual Studio 2015.
Is there any way to add a script that will run my .bat.py file when I click "Start Local Debugger"?
I use UnrealEngine 4 and in my project there already are some .cs files that use precompilation scripts, but these scripts are not fired if the project is already up-to-date.
Any solutions?

Open properties of your startup project in VS (should be your game, not UE4). You need Configuration Properties → Debugging.
When you click Local Windows Debugger (this is what it's labeled in my VS) it runs whatever is specified under Command with Command Arguments. UE4 projects usually have $(TargetPath) and "$(SolutionDir)$(ProjectName).uproject" specified but you can change it to run your .bat script and add custom logic.
However, if your project is not up to date, Build Command Line is going to be called before the debugger (Configuration Properties → NMake). For UE4 that would be UnrealEngine\Engine\Build\BatchFiles\Build.bat script. If you need your logic to run before Build.bat you can put it here. Or replace this script with your own.

Related

How Do I Debug A Notepad++ DLL Plugin?

I am trying to write a plugin for Notepad++ using Visual Studio Community 2013
The dll builds fine from the solution and if I copy it to the notepad++/plugins directory I can test out the functionality. However, I now want to debug it and I can't launch the debugger. I tried following a paint.net guide but I still get the error
Unable to start program .....dll
On my project properties under Configuration Properties - Debugging I have the following set:
Command = C:\tools\Notepad++\notepad++.exe
Working Directory = C:\tools\Notepad++
Configuration Properties - Build Events - Post-Build Event I have:
Command Line = copy "$(TargetPath)" "C:\tools\Notepad++\plugins"
NB: The path is outside Program Files to avoid UAC issues when copying.
What other options could be causing this issue?
Make sure you have a debug build of your DLL built with symbols enabled, and use the Debug -> Attach to Process menu command to attach to the notepad++ process once it's running.
It seems to be related to having multiple Configurations in the solution.
Deleting old and unused ones from the sln and vcxproj files cleaned things up. Then making sure that the configuration options were set to All Configurations fixed it.

Eclipse: add a run configuration in a makefile project

I have an Eclipse project that builds a library, with my own build script (that basically sets some variables, then calls a Makefile). I have set the Build Configuration to run this script, everything is OK: I can compile by just clicking on the Build button.
Now, I would like to test some parts of this lib. In the same project, I have created a C++ source file, with a little main(). I would like to create a run configuration to execute this small test program, but Eclipse tells me that "the binary does not exist" (of course, since I want to build it...).
What is the solution ?

How can I compile binary?

I'm a .net developer by heart and usually write web applications. However I've been given the binary of a small project and I need to compile it (I think).
It is only two files: mfile.h and mfile.cpp. From looking at the code the .h file is a header file that contains constants and the cpp file is the actual codefile.
I created a new C++ makefile project in Visual Studio Pro 2008 and added these but when I try to build it just says Error 1 Error result -1 returned from ''. Project mfile
I honestly have never worked with this type of code before but I want to compile this and start learning. What exactly am I missing?
Wish you were running VS 6, in which case you'd just load the .cpp file, click "build", click "okay" when it says it's going to create a project for you, and off you go.
With VS 2008, you want to:
Move these files into a directory by themselves
Select File -> New -> Project from Existing code...
Accept "Visual C++ Project"
Select the directory where you put the file
Probably select "Console Application Project"
Accept the rest of the defaults (click "Finish").
Now you should be able to (finally) build your project.
Alternatively, you can compile from the command line. In the start menu go to "Microsoft Visual Studio 8.0" -> "Visual Studio Tools" and pick one of the command prompts. When it opens, use cd to switch to wherever you've stored the files. Type:
cl mfile.cpp
to compile.
Do not create a makefile project but a standard Console application project (empty). After the empty project is created, add the two files and hit F5. If there are no errors or missing dependencies, everything should compile and run.
Using the makefile project is not the right approach (for windows at least). You should start by using the wizard for a new C++ project. Add those files to the created solution and build.

How do I build all configurations of a Visual Studio 2008 C++ project on the command line?

I'd like to build all the configurations of a VS 2008 C++ project on the command line. Something like:
devenv TheProject.vcproj /build /nologo
But this doesn't work because the /build command insists on having a configuration following it like this:
devenv TheProject.vcproj /build "Release|Win32" /nologo
Is there a way to get a command line build of all configurations within the vcproj file?
I was thinking you can do what you want with MSBUILD, but it appears that it isn't much better for this than DEVENV.
You still have to specify each configuration on the command line, although it would be easy to write a batch file to accomplish this with either MSBUILD or DEVENV.
It looks like previous versions of the development environment may have supported an "ALL" option, but VS 2008 does not.
http://social.msdn.microsoft.com/Forums/en-US/msbuild/thread/8701b3d0-d5c9-45fb-8dd4-e7700c8caca6/
Not directly, but you can have projects depend on other projects - so you could have an 'all' or 'install' project with a dependacy of everything else.
Haven't used VS in a long time. But the project properties panel used to show the command line generated for linking and compiling a project for a particular configuration. It used to be under the Advanced tab. Will using that directly from the command line serve your purpose? This method will not use the VS IDE at all.
Alternatively,
Steps:
Create a project which has a dependency on all other projects.
Write a script which builds this project with different configurations sequentially. You cannot create a single configuration which encapsulates all other configurations.

How can I build all with MSBuild from the command line?

Is this valid?
MSBuild /t=all /configuration=all
I want to build ALL configurations of all projects in a sln file, etc from the command line using MSBuild in Visual Studio 2008.
I do not want to have to specify them when I call MSBuild, the sln/proj files all have that information. I don't want to change my build script if I add configurations to project files.
So for the target I can use BuildAll. If I leave the configuration empty will it build all or is "BuildALL" valid for configuration as well?
EDIT
essentially what I am asking is given an SLN or VCProj file, I want msbuild to iterate all configurations and build it itself, or alternatively some mechanism that will discover them so I don't have to specifically list them on the command line or in a script.
i.e. I don't want to update my build script when I add or remove a configuration. That seems like a pretty reasonable thing to want to do.
You can't by default build all configurations using MSBuild command line options. In order to do this you need to create a new target (VS Project).
The way I do it is:
msbuild /t:BuildAll /Configuration:"Debug;Release;ContinuousIntegration"
I make a standard Target, and call it BuildAll, and for every project I wanted to automate, I'd just create that Target and make it depend on all the targets you want to build automatically.