Prevent Code Analysis from rebuilding project and dependencies in Visual Studio 2012 - visual-studio-2012

After upgrading our solution to Visual Studio 2012 we are looking to take advantage of the new Code Analysis feature. However, it is taking too long to run, because it is rebuilding the project and dependant projects before it runs, even though the code has not changed and does not need a rebuild.
Is there a way to stop it rebuilding code if a rebuild is not required?

I believe Johns statement above to be incorrect.
In my experience, the projects always get rebuilt regardless of whether they are configured for code analysis or not.
I have a solution with over 100 projects. if I select 1 project and run code analysis on that project only, it rebuilds that project and all projects it is dependant on. It doesn't run code analysis on the other projects, but it still rebuilds them.
So why does it have to rebuild all the child projects to run code analysis?

If you are just starting to use code analysis, then you may be mistaking the symptoms. You are seeing:
e
1. Code analysis takes a substantial amount of time, and
2. During code analysis, the project builds
You may be combining these two symptoms and reaching the conclusion that code analysis is forcing a rebuild of your project. This would be a false assumption. Try this:
Ensure that your projects are configured to not run code analysis upon build
Rebuild your solution. Note how long it takes
Build (don't rebuild) your solution, but this time, note how long it takes
You will find that your solution actually "builds", but since the projects are up to date, the compilers and other tools do not run.
So, it's true that code analysis runs a build of your solution first, but it will be a build like #3 above - nothing has changed, so the tools won't run. Only the code analysis tool (FxCop) will run. This takes longer than you might expect, but it's worth it.
In our environment, I created a "Local" solution and project configuration, copied from "Debug". This configuration is mostly the same as "Debug", but does not run code analysis. This is what our developers use on a day to day basis. When code is checked into TFS, it starts a Continuous Integration (CI) build in the "Local" configuration, again, without code analysis.
On the other hand, the nightly build runs the "Debug" configuration, so it does run code analysis. I find that we don't need the results of a code analysis on every build, but it's damned well necessary once a day.
OBTW, Code Analysis is not new. If you look at that MSDN page you linked to, you'll find a 2010 version of the page in the "Other versions" dropdown. In fact, the code analysis feature was available as a Visual Studio add-in called "FxCop", before it became part of the product.

Related

What azure background process should I use?

So I am getting confused with what is the right approach to implementing code that fires on a scheduled bases within azure.
Originally we were using a standard console app that would be put in the webjob folder on deployment. I found this a bit noddy as we had logic looping and waiting for the right time to fire.
I then tried the azure webjob package https://github.com/Azure/azure-webjobs-sdk-extensions, but see this has gone quiet and the master branch is currently broken! I like because it has a CRON type approach with a function.cs, but now not sure if this is being maintained.
So do people have a preference on how a background process would run, e.g. a scheduled task that would run at 2am every day against a database?
Too much choice and not enough consensus on what the right way is?
Much appreciated in advance
I can think of three options, all of which are valid and can suit your needs. Which one to choose in the end comes down to your requirement specifics and your technical expertise.
WebJobs. These are the most powerful and most difficult to build and maintain. You typically use a dedicated project template in Visual Studio to author these. You can ignore that GitHub link - that's not what you need. Make sure you have the Azure workload enabled in Visual Studio and create a WebJob project.
Azure Functions. These are a more lightweight alternative to WebJobs. There is Visual Studio tooling available for this as well but you also have the option of writing your code directly in the portal. Azure Functions will time out after some period of time, so if your job runs more more than a minute or two this might not be the best option.
Logic Apps. This is more of a power user tool with an easy to use (debatable) designer interface. But it's also incredibly powerful and you can call WebJobs or Functions if you need to from a Logic App.
I could add links but I'm sure you could find them easily enough.

CruiseControl.net project that can skip completed tasks?

A common problem I have with CruiseControl.net is when a project encounters an error (either related to the ccnet configuration or build errors) and once I fix the error I must start the project over from the start. But in some cases this means hours of work that doesn't need to be redone.
Is there a method or design philosophy that will allow me to run sections of projects with more granularity?
I was considering passing in a number when force building and using that to determine which "stage" of the build to start at.

Post Build Event to fire Build of another project

A quick Google search shows all sorts of options for pre & post build events but none seem to cover building multiple projects.
In my solution I have over 100 different projects (literally not an exaggeration) but at any one time I am only working one or two.
Often the two, three etc. being worked on have some connection and so changes to one means all three need to be rebuilt.
Rebuild ALL works but it takes minutes not seconds for all 100+ project to rebuild. Rebuild of just the one only works for the one.
Is there a way in pre build or post build to specify building another project(s).
The thought is when working for a week on say two projects I would specify in post build to also build project X.
Thanks
Open Project - Project Dependecies dialog in Visual Studio and fill dependencies for every project. This should give you desired effect, istead of using Post Build event.

Separate TFS Build excluding a single project

I have a solution that currently builds nicely in TFS. I have just added a Sandcastle help File Builder project to it so that the help files can be generated. Now the solutions takes ages to build locally (it has also doubled the build time on the TFS Server).
In practice I'd be happy generating the help files once per day, or only when specifically requested as part of a build.
I tried creating a separate solution (for a new build) which included the Sandcastle project but I got a warning saying that the projects were already under source control.
What is the best way to configure TFS/the solution for this sort of situation? Can I have two builds that run on separate schedules and include/exclude certain projects in the solution?
You can create a new solution configuration that excludes building your help project. Then in your TFS build you can specify which configuration to build. You could have a CI build that doesn't include your help project, and then a nightly build that includes everything.

Does CC.NET detect modification when a build script performs a checkin

I've been doing some research into finally automating our Development builds and still have one nagging question that I'm hoping the StackOverflow community can solve for me.
My understanding is that an IntervalTrigger when setup properly will check VSS every X seconds for changes and if it finds a modified file, will run my tasks. One of my tasks would be to checkout the AssemblyInfo files and update the version numbers. After these files are updated they would be checked back into VSS.
Thinking about this solution it doesn't make much sense because in my mind, I'm forcing the check for changed files to true every time the trigger fires. Am I missing something here? Is there a way of doing this without triggering an automatic build on the AssemblyInfo check-in?
You can use a Filtered Source Control Block to exclude certain files from the trigger.
I just posted a bunch about my default build process here which may be of some interest to you: SVN Website Development and Deployment Solution
The way I usually configure my projects with CC.NET is to have two project blocks per solution. One configured as an interval trigger that does nothing more than get the latest from my repository, build the solution, and run unit tests. The other is a schedule trigger that does all the things the other one does, but actually publishes a build. This includes changing version numbers, publishing files, etc. This might work in your case, since the change in version would cause the interval project to trigger, but only once.
Checking the automatically generated AssemblyInfo into the version control system is a bad idea, don't do it. You'll get a lot of noise (50% of all commits!) in your history. Also, it does not give you any new information - you can always pull this from VCS. Have your build script autogenerate those files is a good practice, but don't push those changes back!

Resources