I have two solutions, solution1 containing project1 which generates a source file that is compiled into solution2 (having project2). You just build and run solution1, then build and run solution2.
Some of my team members are complaining about the usability of this, so, i've put both projects in one solution, and set them both to run (multiple startup projects). I put a pre-build step in project2 to wait for project1 to finish running, so project2 will be build with the latest code generated when project1 runs.
The trouble is, it doesn't work! Visual studio builds project1, and project 2 is waiting for it to finish running (because then the code project2 needs is generated by project1). But Visual Studio apparently doesn't run any of the projects until they are all done building, so this 'wait for project1' keeps project2 from building (by design) but also keeps project1 from running (although it wouldn't have to).
Is there any way to get around this and perform the functionality I want, or a codearound/workaround?
Visual Studio calculates the build order according to your dependence. If project A depends on project B, Visual Studio will build B prior to A.
In order to change build order just right click the Solution node and select
"Project Build Order"
This fixed the build order but didn't completely solve my problem. It did lead me directly to the solution so I'm editing the answer to make it complete (instead of a comment).
In order to cause it to run Project1 to generate the code, I had to insert a post build step (compile, build-events button in lower right) which was just the name of the assembly (project1.exe). This ran project1, which edited the file that was part of project2, which caused the make logic to see that a file in project2 was newer than project2.exe, kicking off a rebuild of project2 as a bonus. Now you just make the changes to either project, run it with F5, and Boom, it just works, nobody's the wiser I'm generating code.
Just have the two projects in the solution. Set the project 2 as the only Startup project and reference project 1 using a project reference. You can then set the project 1 to always build using the configuration manager in Visual Studio. Project 1 will always be rebuild first as you build/run project 2.
Edit: Also make sure your project dependencies are set up so that your project 2 is dependent on project 1. That's in the menu item Project -> Project Dependencies.
Why was this down voted? It does exactly what he wanted. Just set the build location for the project 1 to the location his project 2 is referencing. I would imagine his resource folder, where ever... It will rebuild his project 1 before rebuilding his project 2 with the most current assembly for project 1.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With