run a project before main project in visual studio - visual-studio

I have a project that I use to convert an input text file to css.
I want to run this project every time I run my MVC project so it generates the newest css file.
I know that I can run a Task in BeforeBuild to achieve this, but it requires that I link to the dll file for my project. (This is a problem because if I use a dll file, then I would have to manually update the dll file
Is there a way I can build and run my first project, then launch MVC?

Right click the MVC project in the solution and select Project Dependencies, then check the project that you want to be built first
That will make sure that the dependency project builds first.
Then right click on Solution, select Properties and select Multiple startup projects in order to run two projects

Related

What is the correct way to manage module dependencies when using Prism?

I'm experimenting with Prism, and I've run into a number of inconveniences caused by the fact that the Shell project does not directly reference the Module projects. The primary inconvenience is that the modules output assembly and it's dependencies are not copied to the shell projects output folder after compilation. I've been successful in using xcopy as a post-build event to copy the target assembly to the projects output folder (which is not particularly nice, but seems to work), but not the dependencies.
Is there a standard way to solve this, or is it mostly ad-hoc solutions? Having to set a post-build event for every configuration in every module seems excessive, so I'd like to avoid it if possible.
There is a simple solution for this. You can set up project dependencies in Visual Studio without creating cross-references in the assemblies.
Open the solution properties and go to the Project Dependencies page. Here, select in the combo box Projects your main EXE that contains your shell. Alternatively, right click your main project in the Solution Explorer and select Project Dependencies... there:
In the Depends on listbox, check mark all your module projects that need to be compiled / copied in the output directory.
You can configure further dependencies for all your projects in the solution (e.g. if you have indirect dependencies between modules).
On changing any project that has dependencies, all dependent project will be rebuilt by Visual Studio and processed according the build configuration (e.g. copied to the output directory).

Automatically build library

I have a Visual Studio project which uses a library (both written in C). Often I make a change to the library as well as the project. Each time I make a change to the library I click on the build button then go back to the project and build that.
What I would like to do is specify something such that when I build my project it checks the library, finds that it needs to be built, build the library then continue to build my project.
Is there a way?
In Solution Explorer, right click on the solution. Select Properties then Project Dependencies. Use the dropdown under Projects and select the project you are building. That will bring up a list of all projects in the solution. Put a check mark on each project that depends on the project you are building. This assumes, of course, that your libraries are also projects in your solution.

Get the StartUp Project of the current sln file on building

Some of my projects have behavior based on the settings of the startup project. I.e. copy the resource to some other directory etc.
How can I get the reference to the startup project (the path to the folder would be also enough) on buildig of a project inside VS 2010?
Regards,
Andrey
Go to TOOLS
Select OPTIONS
Then Start UP
Also check that Detect when file is changed outside of environment.
You need to start every new project from a blank project. If a current project is open, there should be an option to close it before creating or opening another project. It's important not to mix up files from different projects.

How to update assembly assembly references in a web site?

I'm making a build using FinalBuilder Pro 7.
I've an ASP.NET web site and I'm trying to use FinalBuilder's "Precompile Asp.net 2.0 Application" action. Well, It fails.
To build it successfully I need to run Visual Studio, open the web site and either build it manually from within VS or manually update all references. After that it works.
Now the question: How to force FinalBuilder to update those references? Even if I create web deployment project associated with the web site and try to build it with msbuild action it would fail for the same reason. Somehow neither action updates references automatically.
Update: OK. Maybe I need to force msbuild to update references. How to do that?
I found some properties that I can change at msbuild action.
On called ResolveAssemblyReferencesDependsOn I tried to put the value = true. Didn't help.
Any ideas?
There are different types of projects in .NET like library project, website project, web API project etc. As you mentioned in your question it is a website project, so I am going to give you a solution for website project.
You can build a project by two ways. Either you can build by visual studio or you can build by using MS Build. If you build your project by using VS, you can update references of your dependencies by executing the command "Update-Package -reinstall" in package manager console. It will reinstall all the packages automatically.
Please note that, all your dependencies are listed in packages.config file.
Secondly if you have to build your project by MS Build using cmd prompt, to load all the dependencies from nuget, you have to execute nuget.exe. By which all your dependencies will be loaded, but their references may not be updated. So in website project you do not have .proj file. So you can't have access to the references of your dependencies. Now problem is that how you can modify your dependencies references?
In website project reference of an assembly exists in its .refresh file. So you have to modify that .refresh file to update the reference of an assembly in website project.
Have you tried using the 'Build VS.NET Solution' or 'MSBuild Project' actions? Both should resolve your assembly references, provided the reference is set to the right location. This requires that you at least have a project file.
As I understand it, the Precompile action (which uses the MS aspnet_compile.exe - see http://msdn.microsoft.com/en-us/library/ms229863(VS.80).aspx) is designed to re-compile an asp.net application which has previously been built via VS or MSBuild. It does either an in-place compile to improve performance for the first user that hits the site, or creates a deployable application (removing source code etc). It's not meant as an alternative to VS/MSBuild.
I'm not 100% sure I understand the problem, but I believe you need to be able to correct some pathing on an assembly reference automatically.
I created a project to handle this (along with some other things): refswap.codeplex.com

add items to visual studio solution in msbuild task

I have created a msbuild task that minifies and combines javascript and css files that is triggered when my visual studio project is built.
This task adds the minified and combined files to the file system.
However I would like that they automatically be added into the visual studio project. Is this possible and if so, how can I achieve this?
I would recommend against doing this inside the default "Build" target of your project file -- IMO the Build target should be pristine and should do nothing but compile/build the project itself. It also can create headaches depending upon how and when your builds execute in your build lifecycle.
Instead, create a new MSBuild target in your build file which performs this addition for you. I hope you have a main build file outside your Visual Studio project -- this will make everything much easier. Since your CSProj file is just a simple XML (MSBuild) file, it's easy enough to write your own custom task which modified the project to add whatever files you like to it.

Resources