MSBUILD .NET v4 teamcity - c#

I have installed TeamCity Professional 8.1.3 (build 30101) onto a clean box and I am trying to run a new build. I have copied over the msbuild tools from my local dev machine to the new server and placed them in the x86 folder. I have also installed the IIS web role, .net feature, registered IIS from the cmd line, and installed MSBUILD tools 2013. For some reason, I still am unable to compile anything. I get the following error
SGEN An attempt was made to load an assembly with an incorrect format:
C:\Windows\Microsoft.Net\assembly\GAC_64\System.Data\v4.0_4.0.0.0__b77a5c561934e089\System.Data.dll.
Is anyone familiar with this error? I am trying to build an app in .NET v4 using msbuild tools v4.

I was getting this error building a project that targeted .NET Framework 4.5.1. I resolved the issue by installing Microsoft .NET Framework 4.5.1 Developer Pack
You can get the SDK (aka Targeting Pack, aks Developer Pack) for other versions you may want to target at .NET SDKs and Downloads

The solution was installing VS2012 on my build machine. This may not be the most efficient, but it beats installing small packages and chasing around things that need to be registers in the GAC.

Related

Cannot build .NET Framework web app targeting 4.7.2 with VS 2022 installed on a docker container

I can't successfully build basic ASP.NET web app targeting framework 4.7.2.
I built a docker image with a base image for Windows Server Core 2019. On this image I installed VS 2022 Enterprise and took Azure development, .NET desktop development, ASP.NET and web development modules, including recommended ones.
For dotnet core solutions everything works fine, but for dotnet framework I am getting such errors:
packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(31,5): Error MSB3758: An error has occurred during compilation. error CS0014: Required file 'alink.dll' could not be found
packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.2.0.1\build\net46\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props(31,5): Error MSB4175: The task factory "CodeTaskFactory" could not be loaded from the assembly "C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Current\Bin\Microsoft.Build.Tasks.Core.dll". The task factory must return a value for the "TaskType" property.
I additionally installed .NET Frameworks: 4.5, 4.6, 4.6.1, 4.7.1, 4.8, but it didn't help.
Locally, I am able to build it without any problems. I checked the image if VS 2022 was installed without any issues and it looks fine as well. All environment variables are also in place. I thought the issue was related with some missing .NET Frameworks with SDKs, but it still persists.
Installing Redistributable C++ 2012-2022 didn't help as well. I am using MSBuild 17.
What I still might be missing?
I want to create an agent for Azure DevOps and as a reference I use the Dockerfile from Microsoft documentation. One difference is that before the start script, I run my custom script to silently install the VS 2022 with the modules I specified earlier.
I use Azure DevOps pipelines to build the solution, and the VSBuild#1 task.
I was finally able to solve the problem I had. It turned out that the base windows server core image didn't contain all of the needed prerequisites nor Visual Studio. Solution was to use extended windows server core image with sdk 4.8. This is strange, because Visual Studio already delivers everything for sdk 4.8. I think the extended image must have had something else that didn't come with the VS installation.

SqlServerTypes on Windows ARM (arm64)

I'm a fullstack developer and I had the setup where my main development machine was an Intel MacBook for frontend iOS/Android app development, with Windows 10 running in a Parallels VM, with Visual Studio installed for my .NET (Standard) backend. Everything was running fine with this setup.
I've just moved to an M1 MacBook and since I couldn't use Windows 10 x64 anymore, I've setup Windows 11 ARM version, and installed Visual Studio 2022 in it. Visual Studio works perfectly under x64 emulation, but some code in my C# projects have Entity Framework dependencies for custom SQL Server types (spatial types), which have x86/x64 DLLs available (the package was last updated on 2018 and I couldn't find any ARM64 versions). Even though x64 emulation works great when running apps like Visual Studio itself, for some reason I'm getting the following error when I'm building a project which depend on SQL Server Types:
Error Could not copy the file "C:\Users\can\source\repos\MyProjectNameRedacted\SqlServerTypes\x86\SqlServerSpatial140.dll" because it was not found.
Error Could not copy the file "C:\Users\can\source\repos\MyProjectNameRedacted\SqlServerTypes\x64\SqlServerSpatial140.dll" because it was not found.
Error Could not copy the file "C:\Users\can\source\repos\MyProjectNameRedacted\SqlServerTypes\x86\msvcr120.dll" because it was not found.
Error Could not copy the file "C:\Users\can\source\repos\MyProjectNameRedacted\SqlServerTypes\x64\msvcr120.dll" because it was not found.
How can I solve this?
The problem was simpler and more obvious than anything to do with ARM64 or emulation.
I've cloned my repo from Git, and my .gitignore simply was ignoring DLL files as all the DLLs except these particular files were just build outputs. When I cloned the repo, DLLs were simply not there, and build was expecting those DLLs, resulting in error. I've reinstalled the package using NuGet using the following command and the problem was solved:
Install-Package Microsoft.SqlServer.Types -Version 14.0.1016.290 -project Models

Installing Microsoft.Azure.SignalR.AspNet causes method not implemented runtime error when deployed to a server but runs fine on Visual Studio 2017

Error:
Method 'MyController' in type 'MyProject.AppStart.Selector' from
assembly 'MyProject, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=......' does not have an implementation.
Background:
I have an ASP.NET project with target framework set to .NET Framework 4.6.2. After installing Microsoft.Azure.SignalR.AspNet 1.0.0-preview1-103a17from nuget package manager, it builds and runs fine on Visual Studio 2017. No problem at all. When I deploy the release to my server and try to access any of its services, I get the above-mentioned error. The method is implemented in a class which implements System.Web.Http.Dispatcher.IHttpControllerSelector.
Configuration:
The machine on which code works: Windows 10 Version 1809 (OS Build 17763.316). Visual Studio 2017 15.9.6.
The machine on which code does not work: Windows Server 2012 R2 Version 6.2 Build 9200. IIS version 8.5.9600.16384.
What I tried:
Clean/Rebuild deploy again.
Delete obj and bin folder, publish and deploy again.
Deleted CachedAssessmbly as suggested here.
Change Configuration from Release to Debug.
Install Azure SDK in the Windows Server 2012 R2 machine.
Try to install the dependencies of Microsoft.Azure.SignalR.AspNet without directly installing Microsoft.Azure.SignalR.AspNet. It appears that the error starts to Microsoft.Azure.SignalR.Protocols is installed. The dependencies of the Microsoft.Azure.SignalR.Protocols are:
All of these four dependencies are being added when I install Microsoft.Azure.SignalR.Protocols i.e. they are not already being used.
I can't seem to find the issue.
Update:
I deployed the folder on the above mentioned Windows 10 machine and used IIS Manager to create an application. The application works fine on the same machine without Visual Studio.
In the Windows Server 2012 R2 machine, I had originally installed .NET Core 2.2 runtime instead of the SDK. I installed the following in order:
.NET Core 2.2 SDK (deployment still didn't work)
.NET Framework 4.7.2 Dev Pack (asked for restarted, postponed it)
.NET Framework 4.6.1 Dev Pack
After installing the .NET Framework 4.6.1 Dev Pack, I restarted. And now the deployment works.
I can't pinpoint the solution but my guess is that installing .NET Core 2.2 SDK fixed the issue. After it got installed, the installation window prompted some version of Microsoft.AspNetCore has been installed. It didn't ask for a restart but I guess as .NET Core 2.2 Runtime was already installed and being used by another application, a restart was needed.
It is quite strange that Microsoft.AspNetCore wasn't installed along with .NET Core 2.2 Runtime.
It took quite some time to fix this issue as typeloadexception can arise in many other scenarios.
Hope this solution helps other people as well.

In Linux , The reference assemblies for framework ".NETFramework,Version=v4.5" were not found

I have made a setup of Visual studio to compile C# code in my Ubuntu Machine .
I loaded the workspace/my code to VS and I could see the below error.
The reference assemblies for framework ".NETFramework,Version=v4.5" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
Please help me on resolving this issue as am a beginner in Visual studio.
Thanks
If project is heavy, you can follow
this procedure
If your project is lightweight, create a new .netcore project using VS and move your code (and dependencies references)into that new project. then let VS telling you potential errors and correct them.
Looking at the procedure, you can firstly retargeting your actual project in dotnet 4.6.2 framework in order to "ensures that you can use API alternatives for .NET Framework-specific targets in the cases where .NET Core can't support a particular API."
I would recommend running the portability tool in Visual Studio 2017 if you have it. This will give you an idea if you will have a hard time moving it over.
As for your error with the csproj, that's because that file has paths within it, which are pointing to locations using windows paths, instead of Linux paths.

Xamarin Forms Portable Application MonoAndroid Build Error - Framework not found

I've made a fresh Xamarin Forms Portable Project from the Cross Platform templates in Visual Studio 2015. Haven't touched or modified any of the project files. Then When I try to initially build it, I get the following build error:
C:\Program Files (x86)\MSBuild\14.0\bin\Microsoft.Common.CurrentVersion.targets(1098,5): error MSB3644: The reference assemblies for framework "MonoAndroid,Version=v6.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
My Project defaults are:
Looking at similar questions, it would seem that, indeed, that version of the framework is not installed. But it seems to be. Android SDK Manager shows the following:
What is going on here? How can I resolve this.
When you get these type of errors, that are really 'out there' and hint of system configuration problems, it's time to reinstall.
I had to completely remove all remnants of Visual Studio, SDKs and Xamarin. 'Modify' and 'Repair' didn't work.
After the complete fresh install of VS 2015 and Xamarin, things are back to normal.

Categories

Resources