Visual Studio 2012 doesn't build C# project when C++ dependency changes - visual-studio-2012

I have three projects in my solution: a C++ project called LibX, a C# project called LibX.NET which wraps LibX.dll using P/Invoke, and a C# WPF app called TestX.
LibX.NET is marked as dependent on LibX, and TestX copies LibX.dll to its output directory as part of a post-build step (since I can't think of a better way to ensure that TestX can use LibX.dll).
In VS2010, when I change a file in LibX and build, both LibX.NET and TestX are built, and so their post-build event fires and everything is made up-to-date.
However, in VS2012, when I change a file in LibX, VS doesn't build LibX.NET and TestX, claiming that they are "up-to-date". Is this a bug/regression in VS2012, or is it intentional? How do I get TestX to run its post-build step?

If you want changes in LibX to trigger builds in LibX.Net you need to reverse your project dependency between these two projects.
Since you have marked LibX.Net depends on LibX then you will need to compile LiX.Net to get both projects built. When you do that both projects will get compiled/skipped based on whether changes were made. And this is the same behavior in VS2010.

Related

Visual Studio builds njsproj Node.js project even though there are no changes since last build

I've added a Blank Node.js Web Application project to my solution. It is a *.njsproj the among of other C# *.csproj projects.
The project works fine. Visual Studio build runs npm run build according the package.json. There is only one thing bothering me. The *.njsproj is built everytime I build the solution.
Visual Studio can recognize when there is no change in the C# *.csproj projects and skips them saying they are up-to-date:
========== Build: 1 succeeded, 0 failed, 29 up-to-date, 0 skipped ==========
However, this does not work for the *.njsproj. The npm run build (raised from AfterCompile target in Microsoft.NodejsToolsV2.targets) is executed every single time even though there is absolutely no change in any of the solution projects or files at all.
Is Visual Studio even able to track changes of Node.js project to skip the build or there is no chance to make it work similar to the C# projects?
All the Node.js project files have Build Action set to None.
I think it is impossible. This is related to the VS IDE's internal build mechanism for Node JS projects of this type. And it is designed by that.
And I should tell you that the up-to-date check is a feature for VS IDE. You can try the VS IDE Build and MSBuild command line build msbuild xxx\xxx.csproj -t:build with the c# project, and you will find that:
IDE build will not execute any msbuild system target, and it detects that it should not build again since there is no changes to minimize the workload of MSBuild.
However, when you use msbuild command line, no matter there is no changes, it still invokes the many system default targets which will make a burden with a large solution.
So the up-to-date is a feature for VS IDE which will helps reduce the burden of msbuild.
We could only modify target one by one to skip by inputs, outputs. But this is meaningless since up-to-date is a new detection mechanism which is not dependent on MSBuild and Targets. There is no msbuild function to get the up-to-date under node js projects.
That is an internal mechanism We cannot handle that area, you need to contact the Microsoft product team by VS IDE menu-->Help-->Send Feedback-->Report a problem or that.

Prevent a project from building if a dependent project fails

I have a VS2010 solution that includes a custom project. The project builds an installer out of all the libraries and executables built in the same solution. This is a third-party installer builder, not a native Visual Studio installer project. It runs a custom command in the post-build event of the project.
The problem with this setup is that the installer project build runs (and succeeds!) even if some other project build fails.
I have added project dependencies so that the installer project depends on all other projects, to no avail. I have also tried to add project references with the same result.
This happens only with this specific project (probably because it's a custom project with configuration type "utility"). Other projects don't start building if a dependent project fails to build.
This is a dangerous situation. A developer may not pay attention to a build failure in some other project and use the incorrectly built installer. I need MSVC to skip building the installer project if some other project fails.
How should I deal with it?
Ideally this should be solved at the MSVC level. I don't want to add custom checks to the installer build command because this would mean I have to maintain a list of projects/targets in two separate places. I also don't want to introduce additional tools to the picture.

How can i tell visual studio to rebuild project when dependant library has been rebuilt

In my solution i have two projects.
One is a library that generates a .lib file on build.
The other is a test application using the library.
I have set the test project to be "dependent" on the library project.
However when i make changes to the library and press F5 to run the sample, it does not rebuild the sample. The dependency option only seem to make sure that the library is built when running the sample.
"On run,when projects are out of date" is set to "always build".
I'm using vs12.
you have set the Test project dependant on the Library but for this scenario you want that reversed.
Visual studio will not allow you to have a circular reference, so you will have to remove the project dependency for Test to Library and re-add it as Library to Test while you are working in this way.
The most common scenario would be a client app(Test) that is dependant on the Library and any changes on the Library would require a manual rebuild of the client, due to the fact the Library change may have broken signatures, types etc.

does every .exe file need a new project in Microsoft Visual C++?

My background is Linux and traditional makefiles. I have a project where the makefile builds several dozen executables I can then run to perform tests against the library being developed. This library is now ported to Windows.
My question: In Microsoft Visual C++, do I have to create a new project for every individual test .exe file? Or is there a way to create 1 project that will easily build all of the .exe files? E.g., test001.cpp becomes test001.exe, test002.cpp becomes test002.exe, etc.
I'm using Microsoft Visual C++ 2010 Express. Right now what I do is click on File->Add->New Project...->Win32 Console Application->... for every test executable. But it would be nicer if all these test files could be built without a new project for each one.
You need to have one project per executable, but you can have multiple projects per Visual Studio "solution".
When you build a solution, all of its projects get built. If you need the projects to be built in a specific order within the solution, you can easily set up dependencies.
If you're using Visual Studio in the normal fashion, then yes, each VS project (i.e. each .vcproj file) corresponds to exactly one output file (an executable, DLL, or static library).
You can also use Visual Studio with makefiles though, if you want. Just write your makefile as usual, except the C++ compiler is the cl.exe in the VS binaries directory, the linker is link.exe, and of course all of the command line flags are completely different. You can even set your VS project to use make instead of its built-in system, so you can still use the IDE for editing and debugging.

generate exe file

i have developed application in visual c++ 6.0,i have do exe of that application,i have done by using icnt.exe(install creator),but when i run my application exe file on other system which does't have the vc++ software it's showing dll files are missing,how could than i downloaded the dll files again it is asking other dll's files.i want run my application without installing vc++ software in windows,how can i solve it,plz help me i'm touble.
How to make Realease build? by default its debug build
thanks for reply.
As a wild guess, you have deployed the Debug build, which depends on DLLs that are not allowed to be shipped.
If that is the case, have VC6 create a Release build and deploy that.
You can verify which DLLs are required by your application with the depends.exe utility that came with Visual Studio.
Edit: The easiest way to get a release build when ready is to use the Batch Build command from the Build menu. It will let you pick among all of the known build types in the project, and choose to either build them clean (recommended) or to just bring them up to date.
It is also possible to switch the GUI to default to the Release build instead of Debug. That is the right thing to do if you actually need to run the debugger on the Release build. Note that both builds include debug symbols. The differences have more to do with which runtime libraries are linked, and certain optimizations such as making the assert() macro have no effect.

Resources