Cruise Control .NET ignoring project dependencies - cruisecontrol.net

I have been using CC.Net successfully for some time, but now I have a problem. I added new solution to CC. It is compiled fine in VS2008, but fails in CC. The main reason is - projects in solution are built in wrong order, with no regard to dependencies. CC just tries to build them in the same order as they are stored on disc (alphabetical order).
For example, in solution there is proect Proj1 and Proj2, Proj1 has reference to Proj2. On CCNET Proj1 is built before Proj2 and throws error "CSC : error CS0006: Metadata file 'D:\xxx\Proj2\bin\Debug\Proj2.dll' could not be found".
I know this could happen when devenv is used to build solutions, but I use MSBuild.
The following code is responsible for building:
<exec>
<executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
<baseDirectory>code\src</baseDirectory>
<buildArgs>/p:Configuration=Debug /t:Rebuild PM.sln</buildArgs>
<buildTimeoutSeconds>1200</buildTimeoutSeconds>
</exec>
What am I doing wrong?

The error Metadata file could not be found:
When it happened to me, it was because there was a file called proj1.exe at that location that should not have been there. So when it used proj1.exe as the reference (instead of a proj1.dll), proj1.exe's reference to a local System.EnterpriseServices.dll failed. This was happening to me with proj1.exe referencing System.EnterpriseServices.dll which referenced System.EnterpriseServices.Wrapper.dll. Where proj1.exe was not supposed to be included in the build but someone had named a unit test app project against our team conventions.
So I recommend checking the references in the project files(unload project and edit project in vs2010 or open each project file with a text or xml editor) to make sure they are ProjectReference not Reference. Also try doing the build with /v:d in the buildArgs list so you get a more detailed build log that will show you where files were resolved to and in what order. Aa different reference that is 'successfully' resolved could be attempting to load x.dll that directly locally references your D:\xxx\Proj2\bin\Debug\Proj2.dll but fails.

Related

Debug target is an old version of NUnit that isn't present on computer

When trying to debug a project which I have successfully debugged many times before and which compiles without incident, I'm now getting this error:
Visual Studio cannot start debugging because the debug target 'C:\Program Files (x86)\NUnit 2.6.2\bin\nunit.exe' is missing. Please build the project and retry, or set the OutputPath and AssemblyName properties appropriately to point at the correct location for the target assembly.
Looking at Program Files (x86), I can see that the reason VS can't find the file is that it doesn't exist. The version of NUnit it should be looking for is 2.6.4, not 2.6.2.
What I can't find, however, is any way to tell VS where to look. The OutputPath and AssemblyName properties referenced in the error message both seem unrelated to the issue, and there isn't any setting I can find that references NUnit at all, much less a particular version of it.
In following advice from some of the many other questions about this error, I have tried the following without success:
Cleaning and rebuilding the solution
Cleaning and rebuilding the individual projects within the solution
Looking at the project and solution files in a text editor (They all show NUnit 2.6.4)
Making sure the projects are all checked in the Configuration Manager
Checking the projects' debug properties
As stated above, neither the .sln files nor any of the .csproj files contained any reference to NUnit 2.6.2, but I finally found a reference to it in a .csproj.user file for one of the projects:
<StartProgram>C:\Program Files %28x86%29\NUnit 2.6.2\bin\nunit.exe</StartProgram>
Changing the version number there fixed the issue.

Some dll from nuget packages are not copied to /bin

I know that this is a question that has been discussed before but I have a situation that I don't understand.
I have the following projects
Project A
Project B
NuGet Package "log4net"
NuGet Package "ServerAppFabric.Client"
Project A has a visual studio reference to Project B. I'm using both packages in code in Project B and I am building in debug mode. Project B config looks like this.
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.0\lib\net40-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Client">
<HintPath>..\packages\ServerAppFabric.Client.1.1.2106\lib\Microsoft.ApplicationServer.Caching.Client.dll</HintPath>
</Reference>
<Reference Include="Microsoft.ApplicationServer.Caching.Core">
<HintPath>..\packages\ServerAppFabric.Client.1.1.2106\lib\Microsoft.ApplicationServer.Caching.Core.dll</HintPath>
</Reference>
*Why is only the dll-file from log4net copied into the bin folder of Project A and not the Client and Core files? Any help or explanation is appreciated! *
I had the same problem with a somehow complex dependency graph.
Go to the Reference Properties and set Copy Local=True.
Compile and check if the assembly was copied to the bin folder.
If that doesn’t fix your issue try this answer: https://stackoverflow.com/a/19889803/1074245
In order to answer your question precisely, we'd need to know a couple of things.
One explanation depends on what references you have in Project A. For example, it could be that project A, other than referencing project B, also includes additional references, among which there are Microsoft.ApplicationServer.Caching.Client and Microsoft.ApplicationServer.Caching.Core, maybe with the option Copy local set to false - but not log4net. In this case, the copy of the former two will happen only for Project B.
Another possible explanation depends on what your code does with the references in project A and project B. The MSBuild process does not automatically copy assemblies of references that are not actually used in a project.
Finally, in case you are relying on Build Events to copy references, have a look at the Output panel to make sure that there are no errors despite a successful compilation.
In any case, in order to make sure that all NuGet packages are copied, I find it useful to edit the .csproj file and, among the <PropertyGroup> tag, add this:
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
From the documentation:
If you set this CopyLocalLockFileAssemblies to true, any NuGet package dependencies are copied to the output directory. That means you can use the output of dotnet build to run your plugin on any machine.
I don't think this is related to NuGet. It should be related to how references work in Visual Studio or MSBuild. If you just reference a library in ProjectB, it won't show up in ProjectA's bin folder. However, when you use some type from the referenced library,only then it will show up in bin folder.

Error Running Code Analysis in VS2012: Could not resolve type reference

When I click the Run Code Analysis project context menu item. Building starts, but stops with following error:
CA0001 Error Running Code Analysis
CA0001 : The following error was encountered while reading module 'EntityFramework':
Could not resolve type reference:
[System.ComponentModel.DataAnnotations, Version=4.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35]System.ComponentModel.DataAnnotations.Schema.ColumnAttribute. [Errors and Warnings] (Global)
Analysis on other projects works well. How to eliminate this problem?
I tried the solution mentioned by Scott Wylie. I tried adding a reference to System.ComponentModel.DataAnnotations in my project but that did not help.
I then tried copying and pasting the System.ComponentModel.DataAnnotations.dll directly into my bin folder and that did the trick. Add the dll into your local bin folder, publish the solution, then manually add the dll into the bin folder of your published project (if it didn't copy up on its own).
The System.ComponentModel.DataAnnotations dll may not be used by your application but it is internally referenced by EntityFramework.dll. Code Analysis will look at all of your referenced dll's and try to resolve their references too. If you add the System.ComponentModel.DataAnnotations.dll to your application, this error will go away next time you run Code Analysis.

Fail to load manifest error

What does this message means? How to solve this error?
Error 1 general error c1010070: Failed to load and parse the manifest. The system cannot find the file specified. ..\DebugObj\Example1\Example1.exe.intermediate.manifest Example1
I had the same problem on a project I inherited from a pre-2008 Visual studio.
It was not practical for me to add a Main function as sugested by the previous answer. I googled for a while but could not find the root of the problem.
A friend of mine gave me the following solution.
It turns out that the old project included a "example.manifest" file entry in the Resource File Folder in Visual Studio's Solution Explorer for the project. When trying to build the project, VS 2008 was trying to load "example.manifest", which did not exist on the new 2008 folder structor (it was not needed).
So the solution was as simple as removing the entry "example.manifest" from the Resouce Files folder. Rebuilt, and no more errors!. Hope that helps
to fix that error you need to have an entry point in your solution.
just create a main.cpp with a main method... just like this.
in "main.cpp"
void main(){}
then compile and it will get rid of the error.
Had similar issue myself. Converted a VS2005 project to VS2010.
I was using the option, Linker -> Manifest File -> Additional Manifest Dependencies: type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='' publicKeyToken='6595b64144ccf1df' language=''
The conversion garbled it into type=%27win32%27...etc
Fixing this option to the correct format, type='win32'..etc resolved the issue. But not before I accidentally used the format, type=win32...etc and received the same error.

How do I eliminate error C2859 when trying to use a precompiled header with VS2010 (VC100) in debug mode?

I am trying to upgrade an old solution to use VS2010 (VC100).
I have it setup so that stdafx.cpp will create a precompiled header stdafx.pch from stdafx.h. Then all the other .cpp files that include stdafx.h are instructed to use the precompiled header.
These posts helped me get this far:
Visual C++ Precompiled Headers errors
Precompiled Headers
Now all is fine when I build in release mode. However when I try and build in debug mode I get a whole heap of errors saying:
Error 1 error C2859: [removed]\debug\vc100.idb is not the idb file that was used when this precompiled header was created, recreate the precompiled header.
I believe that this .idb file is an intermediate debug file created by Visual Studio.
Why am I getting this error? In other words why did it not use this .idb file when it created the precompiled header?
I'm not sure what further information you need to be able to give me answer so just ask if there is more information that I need to provide.
Thanks to a colleague I got the answer.
The problem was that stdafx.cpp had Debug Information Format set to Program Database (/Zi) where as all the other files had it set to Program Database for Edit and Continue (/ZI).
Changing them all to Program Database for Edit and Continue (/ZI) and doing a full rebuild solved the problem.
I guess the upgrade screwed it up somehow.
I've hit this error with VS2005 when compiling a project where the $(ProjectName) is different from the actual output file of the project (i.e. Linker > Output File isn't set to the default of $(OutDir)\$(ProjectName).exe but to something else, e.g. $(OutDir)\$(ProjectName)-custom_postfix.exe)
In this case, and apparently only when doing a Rebuild-Project-Only, the vc80.pdb seems to be looked up wrongly.
What helped me was to additionally set C/C++ > Output Files > Progam Database File Name to $(IntDir)\$(TargetName).pdb. (Instead of the default vc80.pdb)
select Disable for the Debug Information Format in the Properties page for stdafx.cpp, then go back and select Inherit from parent worked for me.
Maybe your release build is configured to write file [removed]\debug\vc100.idb instead of [removed]\release\vc100.idb? Check the project settings for your release build and make sure there are no hardcoded path components like that.
Here's how I just fixed this error on Visual Studio 2008:
Background:
I have a solution that contains two sub-projects.
One project compiles the .dll;
One project compiles the .exe that used this .dll;
The .exe project is dependent on the .dll project;
Problem: I had both of the projects dumping their output into the same directory, i.e. both "OutPutDirectory" and "IntermediateDirectory" set to write to a common directory in the root, "../$(ConfigurationName)".
Cause of error:
The cause of this error was that when the .dll project was compiled, it created the precompiled header (*.pch) in the same directory as the .exe directory, and when the .exe project was compiled, it promptly overwrote the precompiled header (*.pch) from the .dll project.
The fix:
To fix this, I changed the "IntermediateDirectory" for both sub-projects to "temp", so that the temporary files (including the precompiled header files) were written to different directories.

Resources