Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Auto build a project upon execution

Posted on 2016-07-14
20
Medium Priority
?
99 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
Certified OpenStack Administrator Course

We just refreshed our COA course based on the Newton exam.  With 14 labs, this course goes over the different OpenStack services that are part of the certification: Dashboard, Identity Service, Image Service, Networking, Compute, Object Storage, Block Storage, and Orchestration.

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

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!

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
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…
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

722 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