I have mixed C#/C++ solution in VS2013. One of the C++ projects is getting rebuilt every time I run build even when nothing is changed. In the diagnostic output it says:
1> Project not up to date because the following 1 build inputs were missing:
1> up to date is missing: 'PROJECT_OUTPUT_PATH\TMP_RANDOMGUID.RSP'
When I run MSBuild.exe from cmd line, I get following output:
"…\TMP_RANDOMGUID.RSP" does not exist; source compilation required.
Note that random guid changes every time I run build.
This .rsp file is listed as input file for the task "LIB" among other .obj files.
A lot of projects are dependent on this one, so this triggers a rebuild of almost entire solution.
I found out on MSDN that .rsp is MSBuild response file which contains MSBuild.exe command line switches. It looks like the project is configured so that every compile is through a generated .rsp file, can this be turned off in Visual Studio?
Perform this steps if as apply to your environment:
Delete every single output folder of your solution and projects (typically called "Debug", "Release", "x86" and "x64")
Delete every precompiled output folders of your solution and projects (typically called "ipch")
Delete files *.filters, *.user, *.sdf, *.suo
Invoke msbuild with clean target: msbuild /t:clean
Invoke msbuild: msbuild
It is done. Now you should be able to recompile only the based on file changes.
Related
I am able to run the cpp file if create a project and build the solution but when i add another file cpp there is a error as there can be only one main function in a project.
I don't want to create a project just execute singel individual files in Visual Studio;
I can executehi individual files in Visual Studio Code.. How do I do this Visual Studio.(IDE)
You don't run source "C++ files"; you run executable files. These are built from source files through the compilation and linking process. A VS project represents the sequence of steps needed to build a single compilation product (executable, library, etc).
So if you have two source files, each of which separately builds two executables, that means you want two projects.
If you wish to compile individual files on VS you can simply click "terminal" at the top of the application and then "Run Build Task".
After running the build task with your selected compiler it will create an executable that you can test/run.
for example
I have a file open called main.cpp
After selecting "Terminal" and then "Run Build Task" and selecting the compiler "gcc, g++"
the compiler will produce an executable called main.exe
We have set the parallel execution count to 1 so that all the projects will build one after other.In the Visual Studio settings.
With below command from Devenv.exe we are able to compile the solution correctly.
call vcvarsall.bat x86_amd64
devenv /Build "Release|x64" "w:/Frameworks/Frameworks.sln"
But with MSBuild, with below command, the solution is failing to compile, when I cross check the log, the order of compilation of projects is not correct, not taking from solution file.
call vcvarsall.bat x86_amd64
"C:\Program Files (x86)\MSBuild\12.0\Bin\MSBuild.exe" "W:\Frameworks\Frameworks.sln" /t:build /fl /flp:logfile=Frameworks.log;verbosity=normal /p:Configuration=Release;Platform=x64 /m:1
Any suggestion, how to fix set msbuild to compile only from order mentioned in solution file.
Open your solution in VisualStudio, on the solution explorer right click the solution name and look for "Project Dependencies..." and/or "Project Build Order..."
The UI is self explanatory, so configure as required, save all and try the MsBuild command again.
I want to build many c++ projects in Windows 7,
however building them one by one seems fantastic.
Then, I thought to write NMAKE file manually and run some script,
but it seems also troublesome because I have to write many NMAKE files.
So I want to know is it possible to generate NMAKE file automatically from Visual Studio 2010.
Starting with Visual Studio 2002, there is no longer a way to export your VC++ project files to a Makefile. (That option existed up until VC++ 6.0 but was removed.)
As of VS 2010, the build process for VC++ projects is the same as any other projects: there is a solution file and a set of project files, both of which are recognized by MSBuild as inputs. MSBuild take care of the dependency resolution, build ordering, etc.
The only significant feature that you lose building inside the IDE is parallel builds. If that's your concern, you can run the msbuild command on your solution file and pass in the /m parameter to specify how many simultaneous builds it should attempt.
As far as I know, no one has built any kind of tool or plug-in to parse the .vcxproj files and spit out a makefile, though the file format is pretty well documented XML, so you could always write one yourself. Otherwise, if you really need makefiles for some reason, you'll have to craft them by hand.
You can use MSBuild to build a Visual Studio solution or project from the command line.
Convert it to CMake https://stackoverflow.com/a/9387350/525578
Generate using NMake or Jom generator of the CMake
I have several projects in my solution, one of which has some test scripts that get copied as part of a post build rule, is there a way to run the post build rule with out doing a "rebuild only" for that project when I want them run?
You could use Custom Build Step instead of post-build event and specify some dummy non-existent Output file. In this case Custom Build Step will run on every build even if project itself is up to date.
Quote from MSDN:
In Outputs, specify the name of the output file. This is a required entry; without a value for this property, the custom build step will not run. If a custom build step has more than one output, separate file names with a semicolon. The name of the output file should be what is specified in the Command Line property. The project build system will look for the file and check its date. If the file is newer than the input file or if the file is not found, then the custom build step will run.
I have a tool that generates most (but not all) files that need to be compiled in Visual Studio. The tool reads a configuration file and generates c++ files afterwards. This list can differ from one call to another when the configuration is altered.
I am wondering whether it would be possible to adapt the compiling process to my needs, which would be :
Launch the tool (not needed if configuration file has been modified)
Retrieve new list of C++ files to be compiled (ideally isolated in a folder inside the project)
Compile C++ files
EDIT: Having to close Visual Studio for this process to work is a no-go for me. The idea would be to have cpp files dynamically added as the first step of the compilation process.
Use a pre-build step to run your tool.
Also, create a file containing the list of includes and sources
This file name should be fixed (so that you don't have to change project properties or the vcproj file) -- add it to the project. E.g:
Project Properties > Command Line > Additional Options > #headerListingFile
You are not trying to integrate lex/yacc output with VS, are you?
Would CMake help? It's an automated project manager that generates Makefiles and VS projects for projects you define. Just add a source file, re-run CMake and you're done.
I think what you should do is create a custom makefile and use that for builds.
Please see this page for more information.