Solved

Auto build a project upon execution

Posted on 2016-07-14
20
70 Views
Last Modified: 2016-07-21
Is there a way to tell Visual Studio to build a project (one project of many within a solution) whenever I run the project?
0
Comment
Question by:HLRosenberger
  • 8
  • 7
  • 5
20 Comments
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41710656
  • The F6 key builds a solution.  
  • Whenever you execute a solution the out of date projects are automatically rebuilt.
>>whenever I run the project?  What do you mean by run a project if the above statements are of no use?
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41710713
I meant run the solution.   I have a class library project within the solution that is not added as a reference.   But I would like to build this project every time I run the solution.
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41710720
Whenever you execute a solution the out of date projects are automatically rebuilt.
So - you don't need to do anything.
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41710746
The automatic build is not happening.  Or does not appear to be.  When you say "rebuilt" does that mean the DLL, PDB and XML files are created?
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41710763
All files required to compile dll and exe files are checked for their last time of change and compared to the dll/exe.  Any newer source files will result in the dll/exe being recompiled/rebuilt.
If nothing is being rebuilt then either everything is at the newest version or you have some sort of problem on your system.  For the second you can select the 'clean' sub menu point on the 'build' menu which should delete any dll/exe files the project/solution creates forcing them to be rebuilt from the source files
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 41710784
regarding your comments:

I have a class library project within the solution that is not added as a reference.   But I would like to build this project every time I run the solution.

To be able to show the starting project faster, only the required components are built and only if needed. If your project is not referenced by the starting project (or any dependencies) then it just not built. In that case your only solution is to manually build the solution yourself (CTRL-SHIFT-B).
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41710994
Eric - Yes, that my scenario.  I was hoping there was a way to force a build upon execution, anyway.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 41711007
is your other project you want to compile a .exe or a .dll?
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41711303
DLL.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 41711345
I don't think you can do much (other than full rebuild). It would have been a .exe, you could have started the other project at the same time as your main one.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 1

Author Comment

by:HLRosenberger
ID: 41712720
I thought I read something a long time ago that you can create a "build list" that executes a series of commands??
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 41712734
if you open the properties of your project and go to the "Build events" tab, you will see that you add some commands but I wouldn't go that way.

Can I ask why you need to compile a DLL that is not referenced?
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41712811
The simplest way to do what you want is to actually use this dll in a 'dummy' function - one that isn't actually ever used - so it will be rebuilt when your main exe is rebuilt.  


Note it means the dll will need to be distributed with the exe.  However the only sensible reason I can think of for you having this dll in the solution implies you have a suite of apps/dlls that you will want all built at once for distribution.
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41717811
Eric - yes.  The code I've inherited does a very clever thing.   It has some 10 or so of it's own DLLs that it uses, but none are added as references in the main project.   Instead, each is loaded dynamically at runtime.  To make a long story short, this application supports what it calls "Plugins" - the ability for user to add new functionality to the application, with touching the source code.   In order to debug things, I need the DLL/PDB rebuilt each time I run, otherwise the source code does not match the DLL/PDB.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 41718036
the easy answer: press CTRL-SHIFT-B before F5
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 41718042
or use the pre/post build events to call msbuild to build your projects
0
 
LVL 1

Author Comment

by:HLRosenberger
ID: 41718056
I know how to build it manually.  That's what I'm trying to get around.  pre/post build events?  Tell me more!
0
 
LVL 69

Accepted Solution

by:
Éric Moreau earned 500 total points
ID: 41718059
create a batch file that compile your project and add the call to this batch file in the pre-build events of your starting project : https://msdn.microsoft.com/en-us/library/42x5kfw4.aspx
0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 41718198
>>It has some 10 or so of it's own DLLs that it uses, but none are added as references in the main project.   Instead, each is loaded dynamically at runtime.

If all dll's are installed at the end user PC is there a reason you don't want to just add reference/dummy function to call each in your main app.  Then a build will rebuild them if they are out of date.  My understanding is that the .net environment won't actually compile any of that code from the intermediate into real code until it is called at runtime.
0
 
LVL 1

Author Closing Comment

by:HLRosenberger
ID: 41723402
this sounds promising.  I give it a shot...
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
This video discusses moving either the default database or any database to a new volume.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now