Can MSBuild run regex on my config files? - regex

MSBuild generates a configuration file for me. I would then like to replace certain strings
in the file. Is this possible?
Also, I use Visual Studio as well to build my project. Can I do the same thing from Visual Studio?
Thanks!

Yes it can. Here is an opensource library from MSBuildTasks that has a RegEx replace task in it that can be executed when a project is built. I use it to handle the versioning of assemblies.

Related

how to set configuration of log4cpp for visual studio 2008

i want to use log4cpp library in my code for logging. But,for windows platform i dont know how to configure the library. I am using Visual Studio 2008.
Any help will be appreciated.
Use the workspace and project files in subdirectory msvc8. (You may need to adjust include/log4cpp/config-win32.h and the project files to your particular needs).
You may also opt for compilation of source using cygwin and call exported functions from library.

TeamCity MSbuild C++ only build some solutions

In our C++ project we have several solutions, is there a way to only build select solutions in TeamCity. Or is there parameters for msbuild that can accomplish this?
We are using .Net v4.0
Thanks in advance.
Another possibility is to call MSBuild just on your vcxproj files, not the whole sln files.
We use it very often - we have build batch files compiling just vcxproj files. With sln files we work only in VS IDE.
I guess you have several projects in your solution?
You can create a build configuration (something like Debug/Release) for the whole solution und choose which projects should be built in this. You can pass this configuration's name to Teamcity.

JSONCPP Build with Visual Studio 2010

How do I build it? The documentation is really shady about this. It says you need to place scons.py into the directory, but I have no idea where this is. I have tried using the included prebuild, but it did not produce any .lib files.
No need to use scons.
After you download the jsoncpp source, like from https://github.com/mrtazz/json-cpp, unzip the sources. In this unzipped source tree, under /makefiles/vc71/ you will find several Visual Studio project files which you can up convert and build.
There is a visual studio solution file under makefiles. Did you try migrating that to VS2010 to see if it works?
.py? This is a python script, and has nothing to do with C++. Perhaps you are looking at the wrong instructions.

How to create Visual studio solution from make files?

I have a source code for a project with their make files. I want to create a Visual Studio (2005) solution from it. Is there any direct way to do this? can anyone help me please. I spent hours for searching, but couldn't find a way to do this.
Thanks.
Unfortunately, Microsoft removed this capability after VC++ 6.
If all you're looking to do is to build a Visual Studio project from a command line or script, you can use the devenv command to build using the settings in a project.
Something like:
devenv /build debug /project myproj myapp.sln
Ans starting with VS2010, C++ projects will use the MSBuild system, so you can drive builds using that technology.
If you really want a makefile, you'll need to write it up by hand (or maybe there's some 3rd party tool out there that I'm unaware of).
I'm not sure whether this solution can help you. Which I tried and it worked well in my previous projects. It need manually add the files.
Create a blank VS solution/project. Add the source files into that project.
Mark all source files as "Excluded from building". You can right click the files in project explorer and find the setting. So now nothing will happen when you build your project.
In project setting, find something like "Custom build step". Add the commands that invoke your original build command. (You may write different build command for debug/release ). You can also set the post-build actions such to copy your result to some folder....
Now you can edit and build source files.
For my experience, I can even debug it after setting the executable.
Hope this can help you.
If this is a one-off then it is easier to just create the VS project manually in visual studio.
If you are going to need to do this often look at ceating the project in something like cmake or Qt's .pro whcihc an generate makefiles and VS build files from the same defintion.
Do you want to use the makefile to build? You can create a project from existing source in VS 2005 and setup the project to use make to build (and the wizard will take you through all of this).
I am using VS2010.In order to build you can create a project from existing code. In VS2010 you can create project from existing code File->New->Project from Existing code. You can specify the other parameters and then ready with the solution. I did not go with make file but followed this approach which is working great.

How to use makefiles in Visual Studio?

I heard a lot about makefiles and how they simplify the compilation process. I'm using VS2008. Can somebody please suggest some online references or books where I can find out more about how to deal with them?
The Microsoft Program Maintenance Utility (NMAKE.EXE) is a tool that builds projects based on commands contained in a description file.
NMAKE Reference
A UNIX guy probably told you that. :)
You can use makefiles in VS, but when you do it bypasses all the built-in functionality in MSVC's IDE. Makefiles are basically the reinterpret_cast of the builder. IMO the simplest thing is just to use Solutions.
To answer the specific questions...
I'm using VS2008. Can somebody please suggest some online references
or books where I can find out more about how to deal with them?
This link will give you a good introduction into Makefiles by mapping it with Visual Studio.
Introduction to Makefiles for Visual Studio developers
I heard a lot about makefiles and how they simplify the compilation
process.
Makefiles are powerful and flexible but may not be the best solution to simplify the process. Consider CMake which abstracts the build process well which is explained in this link.
CMake for Visual Studio Developers
I actually use a makefile to build any dependencies needed before invoking devenv to build a particular project as in the following:
debug: coratools_debug
devenv coralib.vcproj /build debug
coratools_debug: nothing
cd ../coratools
nmake debug
cd $(MAKEDIR)
You can also use the msbuild tool to do the same thing:
debug: coratools_debug
msbuild coralib.vcxproj /p:Configuration=debug
coratools_debug: nothing
cd ../coratools
nmake debug
cd $(MAKEDIR)
In my opinion, this is much easier than trying to figure out the overly complicated visual studio project management scheme.
The VS equivalent of a makefile is a "Solution" (over-simplified, I know).
To summarize with a complete solution...
There are 2 options:
Use NMAKE from the Developer Command Prompt for Visual Studio
The shortcut exists in your Start Menu. Look inside the makefile to see if there are any 'setup' actions. Actions appear as the first word before a colon. Typically, all good makefiles have an "all" action so you can type: NMAKE all
Create a Solution and Project Files for each binary.
Most well designed open source solutions provide a makefile with a setup action to generate Visual Studio Project Files for you so look for those first in your Makefile.
Otherwise you need to drag and drop each file or group of files and folders into each New Project you create within Visual Studio.
Hope this helps.
Makefiles and build files are about automating your build. If you use a script like MSBuild or NAnt, you can build your project or solution directly from command line. This in turn makes it possible to automate the build, have it run by a build server.
Besides building your solution it is typical that a build script includes task to run unit tests, report code coverage and complexity and more.
If you are asking about actual command line makefiles then you can export a makefile, or you can call MSBuild on a solution file from the command line. What exactly do you want to do with the makefile?
You can do a search on SO for MSBuild for more details.