Solved

Auto build a project upon execution

Posted on 2016-07-14
20
92 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 70

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 70

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 70

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
 
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 70

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 70

Expert Comment

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

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 70

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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
SQL Time out only from one specific computer client 15 53
Import a excel sheet in a grid 2 45
Error in Visual Project 10 49
ASP.NET VB code for check and insert in a table 4 47
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…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…

752 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