We have set up TFS (2015) with a build server and have several solutions that are built (some manually, others automatically).
Sometimes a build will inexplicably fail, with a lot of errors stating that assemblies are missing, like so:
The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
To fix it I simply need to queue the build again. No edits, no check-ins, just "queue new build", and it builds successfully.
It can happen on manual builds, on automatic builds, on a single build or when building multiple solutions. I can't see any recognizable pattern to why this happens. I don't think it is a nuget issue, because we see different errors when the build server fails at downloading nuget packages (also, is nuget even used for downloading System.Runtime? I assume that library is readily available on the server?)
As I said, it is easy to fix this, but we're using continous integration and automatic deployment (Octopus) to streamline our release cycle, and these "fake" errors are damn annoying when the build error buzzer starts ringing.
Try to set 'MSBuild Arguments' to /m:1 to force MSBuild to use a single process for all projects, to see whether it is helpful.
The issue was, as might be expected, human error. All available build agents were added to the pool for this particular solution, and one of those agents didn't have .Net Framework 4.5.2 installed.The agent was removed from the pool, and if the feedback I got from the sysadmins is correct then the errors should stop occurring now.
Related
We have a legacy solution (>300 projects across several solutions) currently running in the old Xaml build definitions. I'm trying to convert it to the vNext build definitions, but I'm having intermittent errors.
Every so often, a file in the process will become locked, and cause the build to throw the following error:
CSC (0, 0) Metadata file 'E:\Builds\1\3\a\Newtonsoft.Json.dll' could not be opened -- The process cannot access the file 'xxx.dll' because it is being used by another process.
Its a different file every time (this latest was Newtonsoft.json.dll - a nuget package), and not always the same solution. Subsequent builds will work fine.
I've tried to resolve this by adding /NodeReuse:false to the build arguments, and whilst it appears to have reduced the frequency a little, it still hasn't resolved the issue.
Due to the nature of the build, and the fact it relies on the projects outputting to a common location (projects use a combination of File and Project references), I have the following settings configured:
/p:OutDir="$(build.stagingDirectory)" /p:ReferencePath="$(build.stagingDirectory)" /NodeReuse:False
It's almost always the Staging Directory that these dlls are located within.
Reconfiguring the product to exclusively use Project References is unfortunately not viable at this time.
Is there something I can do to the build step to eliminate these locking issues?
Introduction
I have a problem with Team Foundation Server Express 2013 on my machine. I have two build definitions on the same controller and agent, both of which run on the same server and the same environment as well.
It should be noted that I already looked at the "similar questions" without any luck. This is clearly not related to the same root cause, and the symptoms are slightly different too.
One of them is a gated check-in build definition, which just compiles everything when commiting to the development branch.
Another is a scheduled build definition, which runs every saturday at 3 AM, building any changes that may have been committed to the main branch since last time.
The gated build definition has a process (which only has minor changes for not running tests and just compiling the code) based on the TfvcTemplate.12.xaml template.
The scheduled build definition process is based on some Azure build definition template that might come from an older version of Visual Studio, possibly based on some Azure template, or maybe the TfvcContinuousDeployment.12.xaml template.
The issue
My gated build definition runs just as expected, without issues. It compiles the full solution, and only passes if the compilation succeeds.
The shceduled build definition however fails compiling (even before it reaches the point where it runs the unit tests). The error I see is as follows.
Obviously this is due to missing fakes assemblies. I tried taking the assemblies and checking them in (which I would rather avoid), only to find that this build definition runs just fine, but not the gated one which ran just fine before.
I thought about just running fakes.exe in the build template to just generate them manually before compiling, but in my initial tests (to see if this theory would even work), it won't even run in the commandline, and outputs some errors and warnings that I don't understand (but are probably not relevant anyway, since I might be running fakes.exe with improper arguments).
Updates
Update #1
It should be noted that I have Visual Studio 2013 Ultimate installed on my build server as well. Both this (and TFS 2013 Express) have Update 3 installed, and the server is fully updated.
I ended up abandoning fakes all together, and implementing Moq instead. Works a lot better, and forces me to abandon shims or moles, which are often considered bad practise anyway.
I've been tasked with setting up a new Team Foundation/Build server at my company, with which we'll be starting a new project. Nobody here currently has experience with TFS, so I'm learning all of this on my own. Everything is working so far; The server's been set up, the Repository and Team Project has been created, the Build Server has been created, and I've created a simple hello world application to verify the source control and Continuous Integration builds (on the build server) run properly.
However, I'm having a problem setting up the automatic versioning. I've installed the TfsVersioning project, and it's working fine; I'm able to define a format for my assembly versions. I haven't yet decided what format I'll use; probably something like Major.Minor.Changeset.Revision (I'm aware of the potential problem regarding using the changeset number in the assembly version, so I may decide to switch to Major.Minor.Julian.Revision before we begin development).
The problem:
I don't want assemblies to have new file versions if their source code has NOT changed since the last build. With a continuous Integration build this isn't a problem, as the build server will only grab the source files that have changed, causing an incremental build which produces only updated modules; the existing unchanged modules won't be built, so their version will remain unchanged.
If I set up a nightly build, I'll want to clean the workspace and perform a Build-All. However, this means that ALL assemblies will have new version (assuming the Assembly File Version includes the build number).
A solution?
This has prompted me to consider using the latest changeset number in the Assembly File Version. This way, if nothing has been committed between two successive Build-Alls, the versions won't be incremented. However, this would mean that a change and commit to a single file would force a version increment on ALL assemblies.
I'm looking for one of two things:
A way to only increment Assembly Version Numbers if their source/dependencies have changed since the last build. Successive Build-Alls should not cause changes in version numbers.
OR
A way for testers and non-developers to be able to tell version W.X.Y.Z and version W.X.Y.Z+1 of assembly 'Foo' are identical, even though they have differing file versions.
I've probably read about 20 articles on the subject, and nobody (except this guy) seem to address the issue. If what I'm asking for isn't common practice in the Team Foundation ALM, how do I address the second bullet point above?
Thanks for your time!
This is something I did in the past. The solution has two critical points:
You must use an incremental build, i.e. Clean Workspace = None
The change to AssemblyInfo.cs must be computed at each project
This latter is the most complex and I will just draft the solution here.
In the custom MSBuild properties use CustomAfterMicrosoftCommonTargets to inject an hook in normal Visual Studio compile
/property:CustomAfterMicrosoftCommonTargets=custom.proj
Also forward a value for the version
/property:BuildNumber=1.2.3.4
In custom.proj redefine the target BeforeCompile to something similar
<Target Name="BeforeCompile"
Inputs="$(MSBuildAllProjects);
#(Compile);
#(_CoreCompileResourceInputs);
$(ApplicationIcon);
$(AssemblyOriginatorKeyFile);
#(ReferencePath);
#(CompiledLicenseFile);
#(EmbeddedDocumentation);
$(Win32Resource);
$(Win32Manifest);
#(CustomAdditionalCompileInputs)"
Outputs="#(DocFileItem);
#(IntermediateAssembly);
#(_DebugSymbolsIntermediatePath);
$(NonExistentFile);
#(CustomAdditionalCompileOutputs)"
Condition="'$(BuildNumber)'!=''">
<Message Text="*TRACE* BuildNumber: $(BuildNumber)"/>
<MyTasksThatReplaceAssemblyVersion
BuildNumber="$(BuildNumber)"
File="$(MSBuildProjectDirectory)\Properties\AssemblyInfo.cs"/>
</Target>
You need to have a task for replacing the AssemblyFileVersion in the AssemblyInfo.cs source. MSBuild Extension Pack has an AssemblyInfo task for this purpose.
I posted the full details at my blog here, here and here.
I have setup a build controller etc and the builds were failing, I have fixed these now and the build failed properly - as in because of an error.
I have fixed the error and checked the code back in but now the code is not being extracted, although sometimes one folder of many is.
I have deleted the code from the build machine and requeued a build but it keeps failing. It complains that it cannot find the solution that I specified as the build solution.
I have checked the check box to build even if nothing has changed.
Have I missed a setting somewhere for extracting the code?
TFS version is 2012 Express
Visual Studio version is 2010 Professional
I had this issue recently with TFS 2012. I think it boils down to this:
In the lastest build definition files, it appears that it performs a Clean task before updating the workspace. This means that if you do something that causes the Clean part of the build to fail, it will never download the new files in order to fix it.
Recently, I was making big changes to my build file and inevitably made a lot of mistakes, I found that if one of these mistakes caused the Clean to break, I had to go onto the Build server and change the file manually to get it working again.
Does this sound like it might be the same issue?
There are several properties in your build definition you can check. I would start with setting the "Clean Workspace" to All to ensure the correct code is being pulled down and built.
There are other checks you can look at as well like the agent set for the build and the "GetVersion" property. Check the below link out. It should be able to help you in more detail.
Define a Build Process that is Based on the Default Template
I'm noticing some solutions in Team Foundation Server 2008 won't build completely. As in, some number of the projects in the solution succeed but then one fails. The particular failing project says I’m missing an assembly reference. But I'm not - the project has the reference. It builds fine on my PC. I'm looking at the .csproj file that the build agent pulled down and it has the reference, too (it's line-for-line identical to the project I'm building).
The reference in question is to another project in the solution. At first I thought it wasn't building projects in the right order but the build log is telling me that it did (i.e., the project which the reference is in reference to built successfully). So my guess is that somehow on this project (and I’d say about 10-20% of the projects I’m having it build are failing) it’s looking at the wrong folder for assemblies, but I have no idea.
Has anyone ever seen this before?
I did have one Solution which was building things in the wrong order and some Googling seemed to indicate that this was an occasional side-effect of converting a VS2003 SLN file to a VS2008 SLN file (and it was happening in Visual Studio as well), so in that case I made a new SLN from scratch, checked that in "on top" of the problematic one, and it worked fine. But I tried that in the problem above and it didn’t make a difference.
I've seen it on multicore machines where the project dependencies haven't been setup correctly, meaning that tfs starts a project compiling before it's dependencies are finished compiling.
At first I thought it wasn't building projects in the right order but the build log is telling me that it did (i.e., the project which the reference is in reference to built successfully).
Define "built successfully." In particular, make sure the CoreCompile target was invoked and ran to completion. I've seen cases where a different target on the referenced project was built, but that target was insufficient to generate the output the dependent project needed. For example, a web project that includes a Silverlight control will call the GetXapOutputFile target on the Silverlight project -- which is fine & dandy, but it's no replacement for CoreCompile.
If this clue isn't enough to resolve your issue, you should probably post a link to the log and/or the msbuild makefiles.