Build failing on Teamcity - asp.net

Trying to set up a build on Teamcity, never done this before so I haven't a clue what I'm at. It fails with the following error:
C:\Program Files\dotnet\sdk\2.1.4\Microsoft.Common.CurrentVersion.targets(2659,5): error MSB4062: The "Microsoft.Build.Tasks.ResolveComReference" task could not be loaded from the assembly Microsoft.Build.Tasks.Core, Version=15.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a. Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask.
Can anybody help me with this? What does this mean and how do I fix it?

I suppose, you are using .net core build command which does not support this target.
Here is a workaround or just use MSBuild for VS2017. Here is a related thread about the issue: https://github.com/dotnet/cli/issues/9558

Related

Azure Functions Errro - Could not load file or assembly System.Configuration.ConfigurationManager, Version=4.0.3.0

I am working on Azure Functions and these are created in .Net Core version 3.1 whereas the other libraries are written in .Net Framework 4.8. While executing the functions, I am getting following error -
System.Private.CoreLib: Exception while executing function: XXXXXX. System.Private.CoreLib: One or more errors occurred. (The type initializer for 'XXXXX' threw an exception.). XXXX.Service: The type initializer for 'XXXXX.Service.XXXXX' threw an exception. XXXX.Service: Could not load file or assembly 'System.Configuration.ConfigurationManager, Version=4.0.3.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.
Suggestions would be appreciated.
You can work around the issue by adding the _FunctionsSkipCleanOutput to the project file.
<PropertyGroup>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
</PropertyGroup>
Make sure your package version exists. From this it seems that there is no package version in which you reported an error, check this link:
https://www.nuget.org/packages/System.Configuration.ConfigurationManager/5.0.0-preview.1.20120.5
Click Version History, and you will find:

error: GenerateFeatureFileCodeBehindTask task could not be loaded from the assembly

We have ported our project from .NET to .NET Core in order to use an AWS pipeline with Docker containers which requires Linux.
The application builds successfully on our local computers (which run Windows) but in the AWS pipeline the build steps shows this error - GenerateFeatureFileCodeBehindTask ... task could not be loaded from the assembly ... SpecFlow.Tools.MsBuild.Generation.dll:
Full error:
/root/.nuget/packages/specflow.tools.msbuild.generation/3.0.225/build/SpecFlow.Tools.MsBuild.Generation.targets(78,5): error MSB4062: The "SpecFlow.Tools.MsBuild.Generation.GenerateFeatureFileCodeBehindTask" task could not be loaded from the assembly /root/.nuget/packages/specflow.tools.msbuild.generation/3.0.225/build/../tasks/netcoreapp2.0/SpecFlow.Tools.MsBuild.Generation.dll. Assembly with same name is already loaded Confirm that the <UsingTask> declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements
Microsoft.Build.Framework.ITask. [/codebuild/output/src814/src/s3/00/ProjectFoo/ProjectFoo.csproj]
I have found 2 links mentioning this error but no solution - https://ci.appveyor.com/project/SpecFlow/specflow-kx1o3/build/build1119 and https://www.gitmemory.com/issue/techtalk/SpecFlow/1699/520196304.
I have checked and I have no <UsingTask> in my csproj files. Any idea what this SpecFlow task is, and why it is throwing this error?
The GenerateFeatureFileCodeBehindTask is contained in the SpecFlow.Tools.MSBuild.Generation package. It is used to generate the code-behind files of your feature files.
You don't find a <UsingTask> because it is done in the NuGet package.
The GitHub issue for this is: https://github.com/techtalk/SpecFlow/issues/1699/
Currently I have no idea why this error is thrown. But we are currently fixing our build/tests for Linux.

Xamarin.Form could not load Xamarin.iOS on the building of Xamarin.Android

I am blocked with a strange error while building the Android project in a Xamarin.Forms solution.
When I build the Android project I get the following error:
Exception while loading assemblies: System.IO.FileNotFoundException: could not load assembly 'Xamarin.iOS, Version=0.0.0.0, Culture=neutral, PublicKeyToken=8404fff9cb79065'. Perhaps it doesn't exist in the Mono for Android profile?
Has anyone encountered a similar issue?
after all, I did R&N on it neither found any solution for it then I had decided that I will remove #Android Project and again add it with all reference and import NuGet package.
:- when I have followed this step problem has been resolved.

Application cannot load Microsoft.SqlServer.Types Version 13

I am having a problem that many people have had before but none of the existing answers seem to work for me.
When I deploy my ASP.NET project I get an error in the event log saying
Could not load file or assembly 'Microsoft.SqlServer.Types, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
To try to rectify this I installed the Nuget package:
PM> Install-Package Microsoft.SqlServer.Types
This didn't work and I get the same error. So then I followed the readme and used Loader.cs to load the files. Again, same problem. What is happening and why don't the usual solutions fix it?
One thing I did note is that my Microsoft.SqlServer.Types.dll is version 11 not 13? If it makes any difference our database is SqlServer 2016 and our machine is running Windows Server 2008
The way I solved this was to to set the SqlServerTypesAssemblyName in my app. I currently set it in my EntityContext constructor [that inherits off DbContext] to ensure its always set
SqlProviderServices.SqlServerTypesAssemblyName
= "Microsoft.SqlServer.Types, Version=13.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91";
Note your version may want to be different.
Make sure you are reference the correct version of assembly.
If not add manually.
Once the nuget package is installed you can ensure that the dll reference property is set to 'copy local = true'

HttpHandlers x64 problem

I developed a .Net 3.5 x64 web application that includes a custom HttpHandler in the config:
<add path="*.class1" verb="GET" type="ClassLibrary1.Class1Handler"/>
This works when the platform target for ClassLibrary1 is set at x86.
However, when I set this to x64 I get the following error when I run web application starts (it compiles just fine):
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'ClassLibrary1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Does this mean that a HttpHandler can be compiled at x86 only?
That doesn't make much sense to me.
Does anyone have an idea of what could be going on?
Edit 1:
The ClassLibrary1 project is just an empty class library project with a single HttpHandler added (which is also empty).
Edit 2:
I am also getting these warning messages when compiling, I am pretty sure they have something to do with this problem:
Assembly generation -- Referenced assembly 'mscorlib.dll' targets a different processor HttpTest
Edit 3:
I manually edited the project file to force references to the x64 assemblies, like this:
<Reference Include="$(Windir)\Microsoft.NET\Framework64\v2.0.50727\System.dll"/>
This does supress the above warning message, but the problem isn't resolved.
Thanks!
You probably compiled your assembly ClassLibrary1 with the attribute x86. Try to compile it with AnyCPU tag.
One of your dependent assemblies is compiled with the flag set to x86 rather than AnyCPU or x64
See this page for how to use the coreflags.exe to query the assebly in question

Resources