Visual Studio: rebuild solution on each run...how? - visual-studio-2010

I've a Visual Studio project with a pre-build event that copies some dll under the output directory.
I would raise pre-build event whenever that I launch application with F5.
In other words, I would to force solution rebuild on each run. How can I do?

You can force this behaviour by removing your Build-Directory before building.
<YourProject> -> RightClick -> Properties -> Build Events -> "Pre-build event command line" ->
Add something like this here:
rmdir -s "$(ProjectDir)bin\"
rmdir -s "$(ProjectDir)obj\"
Hope this can help somebody, even if this Question is 7 years old now...

Why would you need that? You only need to copy the DLL if it has changed.
Besides that, Visual Studio only builds when it has to, and only rebuilds completely if either it needs to or you tell it to. There is no way to force VS to rebuild if nothing has changed or if it can get away with just rebuilding a single project...

Related

switch built targets in visual studio

I was a CLION user for long, and until recently I switched to visual studio 2017 since CLION uses too much memory.
In CLION, basically I can cmake the whole project with the top-level cmake file and generates multiple targets to select from a drop-down button.
I did the same in visual studio except in visual studio I need to run the cmake first to generate a .sln file and open it in visual studio.
After open this, I can see different class instances(my targets) in the solution explorer, but I do not know where to specify which target to run. Each of my target has its own main function. Also, I have integrates all my targets into a top level object called BUILD_ALL. I can build this build_all which builds all of my individual target. But still i dont know how to run each one.
I tried by using the right-click and start a new instance, but it rebuilds the target everytime which is not wanted. In Clion, this is not a problem.
Could someone help on this?
Thanks in advance.
I would suggest using the Set as Startup Project option. This will make it so the build and debug shortcuts target the selected project.
Right click on the project in the solution explorer and choose Set as Startup Project
Another option is to just build and or debug the project directly from the right click context menu.
Depending on how much you work with CMake and Visual Studio you may want to look into VS_STARTUP_PROJECT

Visual Studio "Clean & Rebuild" in one button?

My solution i'm working on it's has some specialy. And sometime I need to Clean solution and after that Rebuild solution, if not the web application can not access. That why I made a bat file for that work and bind the bat file to a button in Visual Studio toolbar.
But with that way, visual studio just run the bat file, so it clean and rebuild just one solution I'm defined before in the bat file. What I want is a button which can clean and rebuild on solution OPENING, is made a combo of Clean and Rebuild commands of visual studio to just one button.
Is there a way for me?
I'm using Visual Studio 2013.
As #Blorgbeard said,
What is Rebuild Solution?
Rebuild solution will clean and then build the solution from scratch, ignoring anything it’s done before. What it does is deletes all the assemblies, exe’s and referred files to compile again.
What is Clean Solution?
Clean Solution will delete all compiled files (i.e., EXE’s and DLL’s) from the bin/obj directory.
Rebuild means compile and link all source files regardless of whether they changed or not. Build is the normal thing to do and is faster. Sometimes the versions of project target components can get out of sync and rebuild is necessary to make the build successful. In practice, you never need to Clean.

How to execute a command after every build in Visual Studio 2012?

I want to execute a postbuild command after every build, no matter what project in my solution has changed.
To accomplish this in Visual Studio 2010, I made one empty project depend on every other project, so it always got built, executing its postbuild command. However, Visual Studio 2012 (RC) appears to recognize that the dependency is not real, and will not build this empty project automatically.
I do not see any way to specify a solution postbuild script in solution settings. How can I accomplish this?
I have solved this issue by making my post-build script also delete the output (bin**) of this "empty" project, forcing a rebuild of this project every time. It appears to work satisfactorily so far.
This works (for details see original post):
you may need to change security settings (at your own risk) e.g.: https://stackoverflow.com/a/60284384/2705777

Run multiple instances with one click in Visual Studio

I wonder if I can run multiple instances (right now two instances) of my application in debug mode by doing a simple click or set a key for that...
Not many people seem to know this, but this is perfectly possible, though I admit it's not very obvious.
Here's what you do:
suppose your current project is A, and it's output is c:\bin\my.exe
add an empty project to the solution for A, call it 'Dummy'
under Dummy's Project Properties->Debugging set the Command to point c:\bin\my.exe
under Solution Properties->Configuration Manager, uncheck all builds of the Dummy project so VS won't try to build it (building an empty project fails)
under Solution Properties->Startup Project, select Multiple Startup Projects and set the Action for both A and Dummy to Start
now hit F5 and your exe will be launched twice, each under a seperate debugging instance. (as you will be able to see in the Debug->View->Processes window)
You can use "Multiple Startup Projects" feature, but avoid creating dummy projects by hand: just add your debuggee executable into the solution directly:
Solution > Add existing project > Path to .exe
If you neeed several instances, Visual Studio won't allow you to add the same executable twice, but adding a symlink to it with another name works as expected.
MSDN: How to: Debug an Executable Not Part of a Visual Studio Solution
Is Visual Studio 2013 this is even easier!
Project-> Properties -> Debug -> check "Start external program" and click the ... button, navigate to your .exe of the other program.
Then Make sure in your Solution -> Properties -> MultipleStartup Projects that it's checked.
You can run two instances of your application from where it is built; example: d:\test\bin\debug\app.exe and attach both instances to the Visual Studio 2010 debugger.

VS 2010 has all of a sudden stopped auto-checking out files

For some reason Visual Studio has stopped auto-checking out my edits I do to my project. I use VS2005 for the source control and have never had any issues with it like this ever. I haven't made any modifications to the server or my workstation. Has anyone else experienced this? It's a bit tedious to manually check out every file I edit.
Thanks.
Update: As it turns out checking out the entire project/solution and checking it back in fixed this issue. It seems to be an issue files getting set to read-only outside of VSS' control and you have to force VSS to check out everything before it will resume doing it automatically
Did you check your configuration in VS2010?
Tools -> Options -> Source Control -> Environment -> Checked-in items
This blog has step by step instructions to resolve it and some background info, but basically his list is:
Check in everything
Close visual studio
Make sure every file is set to read only in the solution directory (set it on the root solution folder and configure it to propagate to children)
Search for all files under the root projet directory *.user and *.vssscc and delete them
Open VS and load the solution
Check everything back out and then check everything back in

Resources