Visual Studio 2022 was installed on clean Windows 11 using Web Development profile.
Running existing ASP.NET 6 MVC project in it using F5 throws error in build window
NuGet package restore failed. Please see Error List window for detailed warnings and errors.
Error occurred while restoring NuGet packages: The operation failed as details for project MyApp could not be loaded.
Error window contains number of warnings
> Severity Code Description Project File Line Suppression State
> Warning CS8032 An instance of analyzer Microsoft.CodeAnalysis.CSharp.Analyzers.MetaAnalyzers.CSharpDiagnosticAnalyzerFieldsAnalyzer
> cannot be created from
> C:\Users\kobru\.nuget\packages\microsoft.codeanalysis.analyzers\3.0.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll: Could not load type
> 'Microsoft.CodeAnalysis.Analyzers.MetaAnalyzers.DiagnosticAnalyzerFieldsAnalyzer`4'
> from assembly 'Microsoft.CodeAnalysis.Analyzers, Version=3.3.3.10305,
> Culture=neutral, PublicKeyToken=31bf3856ad364e35'..
Will this stop code analyzer? How to fix this so that warnings to not appear?
Usually the NuGet package restore failed... error means that the required package doesn't exist in the NuGet global-packages folder or the package installation is corrupted.
The simplest way to resolve this problem is to install/reinstall the package by using the NuGet Package Manager or perform the following command from the Package Manager console in the Visual Studio:
Install-Package package_name
An additional information:
Install and manage packages in Visual Studio using the NuGet Package Manager
Manage packages with the Visual Studio Package Manager Console (PowerShell)
Related
I'm trying to build an ASP.NET Core Web application .NET Core 3.1.
I run MS Visual Studio 2019, latest build.
I created the "Controllers" folder, an error occurs when trying to add Controller:
Error: there was an error running the selected code generator package restore failed
API Controller empty.
To resolve the issue, I tried the following to no avail:
Delete folders .vs, bin, obj
Clean and Rebuild project
Clear all NuGet caches
Restart, reboot
For what I can find it seems related to:
Error NU1202. Package Microsoft.AspNetCore.Razor 2.2.0 is not compatible with netcoreapp3.1 (.NETCoreApp,Version=v3.1). Package Microsoft.AspNetCore.Razor 2.2.0 does not support any target frameworks.
How can I solve the problem?
Resolved installing latest Visual Studio updates
I've installed Visual Studio 2017 and included the test package and the F# package. I'm trying to run a simple test using xUnit but it says xUnit is not found.
module HelloWorldTest
open FsUnit.xUnit
open Xunit
open System.Diagnostics
[<Fact>]
let ``Say Hello`` () =
Assert.True(true)
Error
The namespace or module 'FsUnit' is not defined.
I tried installing the package with dotnet but that produces an error.
> dotnet add package FSharp.xUnit
Writing C:\Temp\tmp8DAB.tmp
info : Adding PackageReference for package 'FSharp.xUnit' into project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
log : Restoring packages for C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj
...
error: Unable to find package FSharp.Core. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package FsUnit.xUnit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package xunit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package xunit.runner.visualstudio. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package FSharp.xUnit. No packages exist with this id in source(s): Microsoft Visual Studio Offline Packages
error: Unable to find package Microsoft.NET.Test.Sdk with version (>= 16.0.0)
error: - Found 1 version(s) in Microsoft Visual Studio Offline Packages [ Nearest version: 15.9.0]
error: Package 'FSharp.xUnit' is incompatible with 'all' frameworks in project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
So how can I install xUnit for F#? This guide from MS unfortunately is lacking any of this information.
https://learn.microsoft.com/en-us/dotnet/core/testing/unit-testing-fsharp-with-dotnet-test
EDIT:
After adding the NuGet package source
> dotnet add package FsUnit.xUnit
Writing C:\Temp\tmp5BA6.tmp
info : Adding PackageReference for package 'FsUnit.xUnit' into project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
log : Restoring packages for C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj
...
info : CACHE https://api.nuget.org/v3-flatcontainer/fsunit.xunit/index.json
info : Package 'FsUnit.xUnit' is compatible with all the specified frameworks in project 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
info : PackageReference for package 'FsUnit.xUnit' version '3.4.0' updated in file 'C:\Users\mjohn\workspace\fsharp\hello-world\HelloWorld.fsproj'.
I added a new project to the solution. I've added some nuget packages however it fails when building on TFS. It works fine when building locally. I get the following error messages:
C:\Builds\8\Server-Dev-CI\src\.nuget\NuGet.targets (58): The schema version of 'xunit.core' is incompatible with version 2.0.30828.5 of NuGet. Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942.
C:\Builds\8\Server-Dev-CI\src\.nuget\NuGet.targets (58): The schema version of 'xunit.extensibility.execution' is incompatible with version 2.0.30828.5 of NuGet. Please upgrade NuGet to the latest version from http://go.microsoft.com/fwlink/?LinkId=213942.
C:\Builds\8\Server-Dev-CI\src\.nuget\NuGet.targets (58): One or more errors occurred.
C:\Builds\8\Server-Dev-CI\src\.nuget\NuGet.targets (58): The command ""C:\Builds\8\Server-Dev-CI\src\.nuget\nuget.exe" install "C:\Builds\8\Server-Dev-CI\src\Modules\UnitTests.xUnit\packages.config" -source "https://nuget.org/api/v2/" -o "C:\Builds\8\Server-Dev-CI\src\packages"" exited with code 1.
When I open the sources in VS2013 (on the build server) I see the following:
I have to click Restore Packages to get it to work.
I already updated NuGet. Where is it getting " 2.0.30828.5 of NuGet" from???
I figured it out. The whole time I though TFS uses Visual Studio's NuGet, however it turns out TFS runs:
C:\Program Files\Microsoft Team Foundation Server 12.0\Tools\nuget.exe restore
I had to open up console and update nuget:
nuget.exe update -self
I am using TFS 2015 trail version in windows server 2012.I created windows service project in visual studio community edition along with WiX Project to package the windows service. If i build the solution from visual studio, I am able to get the MSI. But if i use Visual studio build in TFS 2015,i get the following error.
"Unexpected exit code received from msbuild.exe: 1" and "Task VSBuild
failed. This caused the job to fail. Look at the logs for the task for
more details."
I refered the below links as reference :
http://wixtoolset.org/documentation/manual/v3/msbuild/wix_with_team_build.html-
http://wixtoolset.org/documentation/manual/v3/msbuild/daily_builds.html
1) I am unable to follow the first link steps as i got struck in step 2:
i am unable to find configuration folder in build definition.
I was reading that we do not have TFSBuild.proj straing from TFS version 2010.
"Right-click on the Build Definition and select View Configuration
Folder." "Check out and open the file named TFSBuild.proj."
2)I am unable to follow second link as well. I am getting below error:
"The imported project "C:\wix\3.8\Wix.targets" was not found. Confirm
that the path in the declaration is correct, and that the
file exists on disk."
since I am new to TFS Build 2015, any help or guidance will be appreciated.
Beginning with NuGet 2.7, the NuGet Visual Studio extension integrates into Visual Studio's build events and restores missing packages when a build begins. This feature is enabled by default. If you are using NuGet to install Wix packages, that's why you can get a successful build from visual studio.
If you want to use NuGet to install Wix packages, you can create one build.proj to restore these packages during build. Check: http://docs.nuget.org/consume/package-restore/team-build
If you don't use NuGet to install Wix packages, a traditional way you can refer to:http://edwinfrey.com/blog/2012/06/11/building-wix-msis-in-tfs-preview/
When i'm trying to create a sitelet project, nuget fails on installing
NuGet Package restore failed for project To2a1.PublicSite.WebSharper: Could not find file 'C:\Users\Michakun\AppData\Local\Temp\nuget\atxvmxdn.eba\tools\net40\IntelliFactory.WebSharper.Web.dll'
Anyone knows why? I'm using visual studio 2013 update 4