ASP.Net website and multi-target frameworks - dependency error - c#

I've got an ASP.Net website (that's really old). One of the projects (let's call it OurCore) that we have in the solution, has been updated to support both .NET Framework 4.6.1, and .NET Standard 2.0.
When I build the solution in Visual Studio, I get this warning: "Could not get dependencies for project reference 'OurCore'". However, I am able to build both Debug and release locally in Visual Studio.
When I attempt to build the solution using a TFS automated build, it fails with this different error:
C:\agent_work\19\s\OurCommon\OurCore\OurCore.csproj : error MSB4057: The target "GetTargetPath" does not exist in the project.
This StackOverflow issue linked below is basically the same thing I am getting, but it has not been resolved. Does anyone have any ideas?
Problem with multi target frameworks in asp web site project

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.

Getting multiple errors while running NUnit Test script on Azure Pipeline

I am working with the NUnit test in visual studio. On visual studio 2019, it running fine with no errors. But when I am making an azure pipeline for the same I am getting the multiple errors in the VSTest step just after VSBuild step.
I am attaching the screenshot defining the errors.
Help me with suitable solution if any.
According to this comment on this GitHub issue:
The problem is that System.Runtime.Loader is not supported on .NET Framework, this is a package that will only work on .NETCore App and UAP. We used to rely on a NuGet feature that wouldn't let this package install when targeting .NET Framework so you would get errors about this at compile time, but they changed this feature and now permit you to install the package and compile, so you now hit the error at runtime which is less than ideal. We could consider building a new version of this package that better stated that it is not supported on .NET Framework so that the incompatibility is found at compile-time.
The only solution seems to be use a different target framework.

Is there anyway to set up automated build task in Team Services for ".xproj" .NET Core project

I my team and I are using Visual Studio 2015, Team Services to build and manage a .NET Core application with multiple .NET Core class libraries all of which are ".xproj" projects. We are now looking to move away from manual builds and follow the continious integration and deployment approach. When adding a build task in Team Services there is a template option for building .NET Core applications. When selected I can see that the restore and build jobs are auto populated with the .csproj extension.
I have changed these to xproj and ran a build only to get the following error for each project in the solution.
Test.xproj'. The file type was not recognized.
2017-05-31T07:24:59.1375560Z ##[error]Error: C:\Program Files\dotnet\dotnet.exe failed with return code: 1
How can I set up a build definition for xproj .NET Core projects?
Any help is appreciated.
Thank you.

The name <object name> does not exists in the current context

Most questions are related with old version of ASP.NET MVC.
My question is related to latest .NET Core build on Framework 4.6. I created a console application and standard class library. I installed all libraries needed for running WEB on .NET Core.
Everything is working fine, views are compiled fine and debugging views also working. Unfortunately, Visual Studio shows the following on any object in view:
The name does not exists in the current context.
How can I get rid of these red underlines?
I am using this technique: Running ASP.NET Core MVC as a Console Application Project without .NET Core SDK
This error occurred in the initial versions of .NET Core and the tooling for Visual Studio: Basically it was as if we were running release (not debug) build. Please upgrade to the latest versions, including Visual Studio 2015 Update 3, and .NET Core tooling.

Web Api Core dependency error

I am trying to open this project on my visual studio 2015:
http://www.codeproject.com/Articles/992208/Angular-JS-Application-with-MVC-Web-API-ASPNET-and
When I open the project I get the following message:
DNX SDK version '....1.0.0-beta4-11566' is required by your solution
but is not installed on this machine. Do you want to install it now?
If you select No, '...1.0.0-rc1-update1' will be used as the solution
DNX SDK Version for this session.
I choose Yes and it failed to install the DNX SDK version so it uses version 1.0.0-rc1-update1.
Then, I get this error:
The dependency Microsoft.AspNet.WebApi.Core 5.2.3 in project ... does
not support framework DNXCore, Version=v5.0.
I am running the most recent version of Visual Studio 2015 and Windows 10. I have tried updating everything, everything is up to date. I don't know why I keep getting this annoying error. I tried using different versions of the WebApi.Core from the most recent to the first version.
It's also important to mention that I am new to the whole ASP.NET 5 concept, I'm used to work with MVC 5 and under.

Categories

Resources