Where do you place all your solutions (global) tasks? Otherwise, an empty project specifically for this purpose?

There are several tasks that I want to run, depending on the solution configuration, when someone creates my solution:

  • In the Release configuration, run Doxygen for the whole solution (doxygen.exe ....)
  • In the Debug and Release configuration, run StyleCop for the whole solution (call the StyleCop target)
  • In the Debug configuration, run FxCop for the whole solution (fxcop.exe ...)
  • and more

These are all tasks of the solution level (global), so it makes no sense for me to add this to every project file. It seems like this would be a common problem, so how do you deal with it?

I think I can create an empty project, make sure that every other project depends on it and will pose all the tasks of the solution level in this ...?

+7
source share
5 answers

I prefer to set such tasks in a .targets file and refer to them from my main projects (approximately those that do not create a library). I could also create a Target in this .targets file that combines a subset of common tasks. Thus, some of my projects can conveniently run sharedtask1 and sharedtask2 , while others run sharedtask1 and sharedtask3 because I just add DependsOnTargets="Shared12" and DependsOnTargets="Shared13" (obviously, I would try to select descriptive names).

These articles have some helpful tips on organizing your msbuild tasks:

Guidelines for Building Reliable Assemblies, Part 1

Guidelines for Building Reliable Assemblies, Part 2

EDIT

To run some tasks, use incremental builds only once, as described in the second article above:

  • In the general .targets file that I hinted at above, create a task in which all your files will be input as inputs, as well as some dummy marker files as output.
  • Make this task the most relevant work you are interested in and update the marker file.
  • Make all your projects depend on a newly created task

When the solution is built, the first project will start the above task, the task will output a marker file and, until your input files change for the rest of the assembly, this task won't start again. Now the disadvantages are this:

  • If your assembly causes the creation or modification of files in the process, the task will run several times.
  • the task will be performed even if you only build one project. This may be the “right” behavior if you are creating documentation. If you want to avoid this, I think you will have to fine-tune the msbuild files very accurately, but I get the impression that you are trying to avoid this.
  • the task will be completed before everything is built, so any task that depends on the built-in versions of assemblies will fail.

To solve the last problem, you will have to abandon the assembly from VS and instead call a special task that will build the solution, and then perform one or more user tasks in the sequence) using msbuild.exe from the command line. I understand that this is probably not the developer experience you are looking for.

+3
source

This question assumes that you want everything to be built every time, which I have not found in practice. Currently, the team I'm working with is very sensitive to build times.

As a result, I suggest you consider the assembly not as a separate thing, but as having several tastes. There "is he building?" build, for which I would bind the Build Selection (only the current project) to the key, until I started using reshaper. There, “give an assembly test” for those who are not testing the device (including those who are developing non-testable ui variables), and if there is a course, that is, “Everything and the assembly of the kitchen sink”, where the documentation, style and any other indicators can to be received.

For this reason, I would suggest using a build server. Extract additional goals and use them when all other work is completed. I would recommend the previously tested TeamCity commit function as a great way for your team to check that they will not break and that they will not create failure conditions, such as reduced coverage.

Also, if you are looking for even faster builds during development, I recommend using NCrunch, which has a highly optimized build process that runs in a second or so, you are editing the file or ContinuousTests.

+3
source

The easiest way to do this is to create an empty project called "Build.csproj". Put it in the solution and make it depend on all other projects. Then for simple tasks, you can use the post-build event to run your tools. If you need more advanced, you can change the project to Build a goal.

It has a few nice things:

  • It is easy and simple to set up and understand.
  • This usually does not interfere with debugging, as you are setting up another project as a launch.
  • You can create configurations that ignore the project.
  • Assuming you stick with post-build events, it allows you to integrate VS without warning.
+3
source

Maybe I missed something, but why not create a solutions folder containing various scripts that will perform your subsequent build tasks for the selected goals and call them from the post build event of your projects? I.e.

  • PostBuildScripts (solutions folder)
    • FxCop.Debug.Target
    • FxCop.Release.Target
    • StyleCop.Release.Target
    • StyleCop.Release.Target
    • Doxygen.Debug.Target
    • Doxygen.Release.Target
    • Others.Release.Target
    • Others.Release.Target

... etc.

These scripts cause calls to run your next task against the target build type; if you really do not want to run it against a specific type of assembly, just leave it empty.

Build in your projects:

/ PostBuildScripts / FxCop. $ (ConfigurationName) .TARGET

/ PostBuildScripts / Doxygen. $ (ConfigurationName) .TARGET

/ PostBuildScripts / StyleCop. $ (ConfigurationName) .TARGET

/ PostBuildScripts / Others. $ (ConfigurationName) .TARGET

... etc.

+1
source

In our solution, we put such assembly actions in our launch project, because we do not want to place it in each project, and our current project refers to all other projects. Thus, all the actions that are performed on the postbuild actions of this project will be performed after all other projects are completed.

+1
source

All Articles