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.
Related
I have a large solution which I have updated from .NET Core 3.1 to .NET 7
This is all compiling on my local development machine
However, I get lots of failures when I build via DevOps pipeline
For example,
Has anyone had this issue? It really concerns me that this works on my local machine but not the pipeline and that key packages such as Auto Mapper are saying not supported on the pipeline, but compile fine locally
My pipeline is shown below
Your workaround for installing the latest nuget could be the only solution currently.
You could check this github ticket Nuget_Tool_Cache_issue#16800, a lot of developers are confused with this behavior.
Same issue was observed when I was trying to investigation further in this ticket. I suppose that it could be by design that the old Nuget 4.1 could not recognize the compatibility between the packages with the latest .Net 7.0
You could also raise a feature request ticket to raise more concern for future update on this behavior.
I will leave this question here as the issue is subtle
The windows-latest image doesnt have a recent version of nuget installed, its only 4.1
I fixed by adding the following before the nuget task
- task: NuGetToolInstaller#1
inputs:
versionSpec: '6.3.1'
checkLatest: true
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.
I've been asked to investigate why our build process is failing when it's being ran on a machine that has Visual Studio 2022 (Version 17.0.0 Preview 3.1) installed on it. I'm not very familiar with C#, MSBuild, or NuGet packages so I may be asking a nonsensical question! Please be patient.
Our C# build app tries to create an instance of Microsoft.Build.Execution.ProjectInstance, as follows:
var pi = new ProjectInstance(projectFile, BuildProperties, null);
Where "projectFile" is the location of a an XML script for MSBuild. But this call causes the following exception:
Microsoft.Build.Exceptions.InvalidProjectFileException: 'The tools version "Current" is unrecognized. Available tools versions are "2.0", "3.5", "4.0".
If I try changing the null argument to "16.0", "17.0", or "Current" I get variations on the same exception.
(If I try to use msbuild.exe directly, it says that it's "Microsoft (R) Build Engine version 17.0.0-preview-21380-01+b6e7d6051 for .NET Framework", although I accept that this may be a red herring since we're automating MSBuild, not running msbuild.exe directly, so apologies if this is irrelevant.)
I have the latest NuGet Microsoft.Build packages (v16.11.0) referenced from the build app project. I notice there are no v17 packages (yet).
Are we doing something fundamentally wrong here? Why do we get this exception? It seems unusual that the exception's message says that the only tools are really low version numbers. I would have expected it to say that the tool version are more like 16, 17 etc, but not "2.0"! Is the ToolsVersion argument in the ProjectInstance constructor related to the version of the NuGet packages (16.11), or to the version of MSBuild that was installed with VS2022 (17.0 preview), or something else entirely!?
All help very much appreciated. If I've worded the question badly, or you need more info to assist, then please ask.
I've installed the preview of .NetCore 3.0 and tried to run the blazor template Blazor (ASP.NET Core hosted) in Visual Studio 2019:
The error that occured, was the following:
NETSDK1045 The current .NET SDK does not support .NET Core 3.0 as a target. Either target .NET Core 2.2 or lower, or use a .NET SDK version that supports .NET Core 3.0.
During these days I had to overcome this issue on a number of different development machines/containers: eventually, I found no less than 6 different reasons that could cause this kind of error:
Missing .NET Core 3 SDK (x86 or x64)
.NET Core SDK preview support not enabled in VS2019
VS2017 instead of VS2019
Wrong SDK path in PATH environment variable(s)
Wrong SDK path in MSBuildSDKsPath environment variable(s)
Wrong SDK version in the project's global.json file
The workarounds for those scenarios are pretty easy to understand, you basically have to either install the proper SDK or remove the "offending" SDK reference(s). However, I did my best to document them all in this post on my blog.
Following this comment, I managed to resolve the problem by installing the x86 version of the .NET Core 3.0 additionally to the x64 version. The build worked after restarting Visual Studio (2019).
for me the solution was removing a path variable MSBuildSDKsPath - Because of exploring preview sdks's i at some point declared that variable to fix another sdk bug - seems like that force sets the used version. So in my case it was set to 3.0.100 and resulted in errors when attempting to use 3.1.300
I got the same error and resolve it with checking the option "Use previews of the .NET Core SDK (requires restart)".
Open Tools > Options and try looking at "Preview Features" or ".Net Core" depending of your Visual Studio version.
Watch out of VS updates, they can disable it.
This is a very hacky-feeling solution but at least it worked. Let's say you've installed the SDK for 3.0.100-rc1-014190. It shows up in dotnet --list-sdks as expected but still doesn't seem to be detected by Visual Studio, and you get the same NETSDK1405 error when trying to build or test anything from the dotnet CLI.
Look in your dotnet SDK install directory (usually C:\Program Files\dotnet\sdk). You should see your preview SDK in there. Either create a copy or rename the existing folder to remove the preview version suffix. For example 3.0.100-rc1-014190 would instead become 3.0.100, like so:
Doing this made .Net Core 3 preview support finally work in VS2019 Preview 4 and the dotnet CLI for me.
For me it was as simple as enabling the preview in Visual Studio 2019. Unfortunately most posts that show how to do this are I believe out of date. I finally came across this stack overflow post How to enable .NET Core 3 preview SDK in VS2019? They moved the check box and it was not on by default for me.
This was a frustrating issue to track down and after doing all of the updates to VS and still not being able to install I tracked it down to an environment variable. Try removing MSBuildSDKsPath and see if that fixes your issue.
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