MVC Solution builds locally but not on TeamCity - c#

Please can somebody help.
I have a solution that build locally and on another machine when checked out from Subversion however when I try to build it using the MSBuild tool on my TeamCity server I get some form of assembly referencing problem
[08:33:32][Csc] Controllers\AccountsController.cs(422, 26): error CS1061: 'PF.ENTITIES.PF022.Item' does not contain a definition for 'OperationStatus' and no extension method 'OperationStatus' accepting a first argument of type 'PF.ENTITIES.PF022.Item' could be found (are you missing a using directive or an assembly reference?)
The PF.ENTITIES.PF022 assembly does have the correct property for OperationStatus and as I said it runs fine locally.
Can somebody help?
Thanks

Have you checked if this dll is set as "Copy locally"?
To set the Copy Local property to True or False
In Solution Explorer, click the Show All Files button to display the References node.
Open the References node for the project.
Right-click a reference in the References list, and click Properties.
The properties associated with that reference appear in a list in the Properties window.
Select Copy Local from the left-hand column, and then click the arrow in the right-hand column to change the value to True or False.
https://msdn.microsoft.com/en-us/library/vstudio/t1zz5y8c%28v=vs.100%29.aspx

It was a problem with Project Dependencies.
I wanted to build the whole Solution in TeamCity but I would now advise against this. Rather build individual projects always within the solution, that way you can arrange your build order and set some dependencies (do the same for your CI Deployment System too)
That way you can ensure certainly libraries are in place before you build other projects.

Related

VS 2015 CS0234 False Error

Other Resources Checked/ Ideas tried
Don't understand why we're getting error CS0234
Type or namespace name does not exist
Cleaning the solution then rebuilding.
Removing the obj and bin folders completely for both projects.
Setup
Visual Studio 2015 update 3
.net 4.5
I currently have a solution with 2 projects. 1 project has a direct reference to the other project, they are both .net 4.5. For simplicity, I will call the project that is being referenced 'A', and the project that is referencing A - 'B'.
While developing in B I have full IntelliSense on classes within A. As soon as I build the solution, project A builds successfully, but project B has several errors as such:
The type or namespace name 'x' does not exist in the namespace
'projectName' (are you missing an assembly reference?)
When I double click the error to navigate to the file I see the error on the 'using' statement for about 1 second, then it disappears along with the error from the error list. I can continue clicking through the entire error list until the error list is empty, but as soon as I rebuild the errors reappear.
Any help would be greatly appreciated.
Verify if project B is referencing other dll files that use a higher Framework version than 4.5, also, I have experienced this problem due to some Nuget packages that had to be added in every project that referenced the original one using the package.
Try taking a look at your Project Dependencies. To do this:
Right Click on your Solution and select Properties
Then on the left side of the screen select 'Project Dependencies'
Make sure that Project 'B' depends on Project 'A'.
This will assure that the projects are being built in the correct order. It should already be set this way, but sometimes Visual Studio doesn't set the dependencies up correctly.
Also, make sure that you don't have any references to Project 'A' in Project 'B'. That would create a circular dependency and give you no end of grief.
do you have a file reference or a project reference. If its a file reference (ie you pointed at the output dll of project A) then you need to ensure that the project dependencies say that B depends on A so that they get built in the correct order

The type or namespace name 'BussinessLib' could not be found (are you missing a using directive or an assembly reference?)

I have a web ASP.NET project with the bellow structure:
I copied this solution to my test computer and now I get
The type or namespace name 'BussinessLib' could not be found
HousingSurvey is the startup project .
Each project get built successfuly but when I try to build the solution I get
The type or namespace name 'BussinessLib' could not be found
As you see BussinessLib is a reference for Housingsurvey. The using BussinessLib statement is set correctly in the HousingSurvey .
So I rebuild BussinessLib and add the reference to Housingsurvey. Housing Survey as a project builds successfully. but again when I build the solution I get The type or namespace name 'BussinessLib' could not be found
To make things stranger when I check
C:\CSharpTest\HousingSurvey\HousingSurvey\BussinessLib\bin\Debug
BussinessLib.dll is deleted somehow(After I build the solution). I double checked BussinessLib.dll and saw it does get created there whenever I build the BussinessLib project.
I found the most promising answer here:
The type or namespace name could not be found
But above answer did not help me since all of 3 projects in my solution are targeted to the .NET Framework 4.5
Any feedback is greatly appreciated.
Update: please note that this whole solution builds "Successfully" in my UAT computer. Then I copy paste it to the test computer and it fails on build.
For some weird reason, whenever I build the whole solution, Business.dll gets deleted from the bin folder! and that's why code that references it can not find it.
From the HousingSurvey Project, delete the reference to BusinessLib and re-add it again. It is probably an issue with a file path for the original reference.
Also when you add the reference to the project again, be sure to set the 'Copy Local' property to True
In Solution Explorer, click the Show All Files button to display the References node.
Open the References node for the project.
Right-click a reference in the References list, and click
Properties. The properties associated with that reference appear in
a list in the Properties window.
Select Copy Local from the
left-hand column, and then click the arrow in the right-hand column
to change the value to True or False.

missing references at debug time

hi there i know its most be a silly mistake but i couldn't find it. i add two references to my project by Right click on References and browse them, i simply use component of these Dlls in my program with no problem, auto complete code is work fine for classes of these Dlls. But when i run my program got error like:
The type or namespace name 'GlobalizationDateTimePicker' does not exist in the namespace 'GHDiamond.Windows.Forms' (are you missing an assembly reference?)
for this line in myform.Designer.cs:
this.DateTimePicker_AZ = new GHDiamond.Windows.Forms.GlobalizationDateTimePicker();
References names are: GHDiamond.dll and GHDiamond.Win.dll. they are in Object browser too when a add them, but when i Build my project, GHDiamond.Win is not there anymore ! any help will be appreciated
Select the Reference in the Solution Explorer and go to the property window. Make sure that the property "Copy Local" is set to "True". This causes the dll to be copied to the output directory.
I have had something similar which was caused by missing dependent dlls. Autocomplete worked until i built then i would get a load of compile errors. make sure there are no other dlls that you need.

ClickOnce deployment error due to Microsoft.VisualStudio.Shell.Interop.9.0 Version9.0.0.0 missing from the Global Assembly Cache (GAC)

I am developing a C# application in VS 2010 that is to be deployed via ClickOnce. However when I try to deploy the application on a client machine I get the following error:
Unable to install or run the application. The application requires the assembly Microsoft.VisualStudio.Shell.Interop.9.0 Version 9.0.0.0 to be installed in the Global Assembly Cache (GAC) first.
I have tried to include the missing assembly into the application files under Project Properties->Publish tab, but the error remains the same. Next I tried to add Microsoft.VisualStudio.Shell.Interop.9.0 to the project's references, but I cannot find it in the reference list.
Does anyone have any tips or solutions to this problem. Thanks in advance.
Try this:
In Solution Explorer, right click the project name and select properties.
Go to the References tab.
Click the Unused References button.
Save and Publish.
Vron's answer is correct, it is a good idea to remove references to unused assemblies. I think if you understand why its happening then you know how to fix it. VS doesn't think you need the assembly when you publish your program because you haven't used it (as far as it can tell) but you have added it to your reference list. So it doesn't package it.
You either need to remove it from your reference list, or you need to ensure it is included in your project. To do this, show hidden, right click on the reference that is missing, click properties, and set "Copy Local" to true. Worked for me and MySQL.

Project Dependencies in Visual Studio

I have a three projects in the solution WinSync. I have WinSyncGui, WinSyncLib and Setup. WinSyncGui requires files from WinSyncLib. How can I get it to include WinSyncLib in WinSyncGui?
VS complains The type or namespace name 'WinSyncLib' could not be found (are you missing a using directive or an assembly reference?)
I've set the dependencies so that WinSyncGui depends on WinSyncLib (so Lib is built first), but it's still not working.
Right click your project (WebSyncGui) and select Add Reference, Projects tab, and then select the project you need to reference.
You need to add WinSyncLib as a reference in your WinSyncGui project.
Adding a project reference.
I've set the dependencies
That sounds wrong. Did you set the "dependencies" or did you set the "references". Dependencies just determine build order, references are used to link projects.
Are you sure all of the types are public? if you omit the modifier, it's internal by default.
Right click on solution, choose Project dependencies and set dependencies whatever you want. It's useful, for example, when you have two exe files in one solution. It's bizzare to add another exe as reference, so I use this option to firstly build depended executable, and then post-build event is copying it into target directory. Very useful toy.

Categories

Resources