cant Install [.net core] packages using visual studio code(dotnet cli) - asp.net-core

I using the latest asp core 3.1 framework. I am trying to setup my database but there is an issue. I can't seem to install the following packages
dotnet tool install --global dotnet-ef
dotnet tool install --global dotnet-aspnet-codegenerator
dotnet add package Microsoft.EntityFrameworkCore.SQLite
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
dotnet add package Microsoft.EntityFrameworkCore.SqlServer
I get the following errors. will appreciate it if any one can help with
a solution.
error NU1100: Unable to resolve 'dotnet-aspnet-codegenerator ' for '.NETCoreApp,Version=v3.1'.
error NU1100: Unable to resolve 'dotnet-aspnet-codegenerator ' for '.NETCoreApp,Version=v3.1/any'.
The tool package could not be restored.
Tool 'dotnet-aspnet-codegenerator' failed to install. This failure may have been caused by:
You are attempting to install a preview release and did not use the --version option to specify the version.
A package by this name was found, but it was not a .NET Core tool.
The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
You mistyped the name of the tool.
This happens when I try to install any of the packages.

Related

Unable to install Dotnet Stryker

I have tried the below commands to install dotnet stryker to my project to improve the mutation testing but getting below error message and it does not allow me to install the tool.
Could you please help on this.
Thanks in advance
PS C:\Users> dotnet tool install -g dotnet-stryker
C:\Program Files\dotnet\sdk\6.0.101\NuGet.targets(130,5): error : Unable to load the service index for source https://api.nuget.org/v3/index.json. [C:\Users\AppData\Local\Temp\evv2az1v.kwa\restore.csproj]
C:\Program Files\dotnet\sdk\6.0.101\NuGet.targets(130,5): error : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. (api.nuget.org:443) [C:\Users\AppData\Local\Temp\evv2az1v.kwa\restore.csproj]
C:\Program Files\dotnet\sdk\6.0.101\NuGet.targets(130,5): error : A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. [C:\Users\AppData\Local\Temp\evv2az1v.kwa\restore.csproj]
The tool package could not be restored.
Tool 'dotnet-stryker' failed to install. This failure may have been caused by:
* You are attempting to install a preview release and did not use the --version option to specify the version.
* A package by this name was found, but it was not a .NET tool.
* The required NuGet feed cannot be accessed, perhaps because of an Internet connection problem.
* You mistyped the name of the tool.
Below commands are also getting the same error message
PS C:\Users> dotnet tool install -g dotnet-stryker dotnet tool install --global dotnet-stryker --version 1.0.0
This is most probably not related to Stryker but to some weird NuGet situation. You can check it by installing some common tool, e.g dotnet-reportgenerator-globaltool. I think I have seen this kind of error when setting up local feeds for dev purposes.
So try this:
dotnet nuget list source - list feeds
dotnet nuget remove source <feed_name> - remove everything you don't need or understand
And then try installing Stryker once again.

How to connect npm with NuGet packages?

I've started a Fable project using a starter template. In order to run it, I was previous successfully using npm run build.
Using Visual Studio, I installed some NuGet packages (Serilog, Dapper) but now when I call npm start, the terminal complains that the NuGet packages calls cannot be resolved:
ERROR in ./src/Project.App/App.fs
Module Error (from ./node_modules/fable-loader/index.js):
C:/Users/markr/git-repos/SampleProject/src/SampleProject.App/App.fs(95,12): (95,47) error FABLE: Cannot resolve Serilog.Log.Error
# ./src/SampleProject.App/SampleProject.App.fsproj 1:0-25 1:0-25
It makes this same complaint for all NuGet package calls. How do I make it so that I can run npm run build while using NuGet packages?
It turns out what I'm trying to do is impossible. Using SAFE architecture now to be able to properly implement a NuGet side (server) and an npm side (client)

aspnet-codegenerator: No code generators available, Even after adding Microsoft.VisualStudio.Web.CodeGeneration.Design

Unable to generate scaffolding using aspnet-codegenerator, below is what I tried:
Created an ASP.Net RazorPages application using
dotnet new webapp
Did a dotnet build
Installed dotnet-aspnet-codegenerator using
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
Ran dotnet aspnet-codegenerator --help
It says: No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.
Added the package mentioned in step 4 using
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
Package added is:
<ItemGroup> <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="3.1.4" /> </ItemGroup>
Again ran: dotnet build
Final-Step
Ran dotnet aspnet-codegenerator --help
Again it says: No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet package reference.
.Net core installed version: 3.1.401
Os: Ubuntu 20.04
This is already a few month old, but I ran into it recently for all my projects.
In case someone else lands on this page, the solution in my case(MAC OS), was to uninstall and reinstall dotnet-aspnet-codegenerator.
Run in terminal:
dotnet tool uninstall --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4
I have same problem when upgrade from .net core 3.1.4 to 5.0.1.
My solution:
update global tools:
dotnet tool install --global dotnet-aspnet-codegenerator
dotnet tool update --global dotnet-aspnet-codegenerator
dotnet tool install --global dotnet-ef
dotnet tool update --global dotnet-ef
add/update links to packages
dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.EntityFrameworkCore.Design
Replace string netcoreapp3.1.4 to net5.0 in .csproj and launch.json files
Clear directories
bin
obj
Rebuild project
Finally run:
dotnet aspnet-codegenerator --help
If all fine it will show available generators.
The root cause of this problem has been described in this issue as the .NET code expecting a case-insensitive filesystem which fails on a Linux host.
A suggested workaround would be to temporarily mount you ~/.nuget directory on a vfat filesystem.
To do so create a dummy file holding the filesystem
dd if=/dev/zero of=/tmp/mynuget bs=1024k count=2000
mkfs.vfat /tmp/mynuget
and then mount it
sudo mount -o uid=myuser,gid=myuser -t vfat /tmp/mynuget /home/myuser/.nuget
and use it
dotnet restore
dotnet aspnet-codegenerator ...
I test your command,and when I do this dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.4,I can get
and then Ran dotnet aspnet-codegenerator --help,I get the same message No code generators are available in this project.Add Microsoft.VisualStudio.Web.CodeGeneration.Design package to the project as a NuGet with you,
but when I do the following,I can run without the message:
I think maybe the package is not added correctly,you can try to remove and add it again.
dotnet remove package Microsoft.VisualStudio.Web.CodeGeneration.Design
dotnet add package Microsoft.VisualStudio.Web.CodeGeneration.Design
I have found the SOLUTION to this issue:
The newest versions are giving some problems, so you will have to downgrade the version of the sdk to the 3.1.3 by writing this command on the terminal:
sudo apt install dotnet-sdk-3.1=3.1.301-1
After that you will need to install the following:
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.3
After that you will need to add the right Web.CodeGeneration.Design Package by writing this on the terminal:
sudo apt install dotnet-sdk-3.1=3.1.301-1
dotnet tool install --global dotnet-aspnet-codegenerator --version 3.1.3
That has worked for me!!

hiredis rebuild with .net framework 2.0 error

I tried remove and install the related files for .net framework 3.5 (include the 2.0). Suggested in this stackoverflow
Tried to install visual studio 2005 as suggested in the second thing that was suggested in the error.
I cannot find hiredis folder under node_modules.
Other thing I tried to clean my cache and delete node_modules and reinstall again as suggested in this stackoverflow.
MSBUILD :
error MSB3428: Could not load the Visual C++ component "VCBuild.exe". To fix this,
1) install the .NET Framework 2.0 SDK,
2) install Microsoft Visual Studio 2005 or
3) add the location of the component to the system path if it is installed elsewhere.
[D:\path\src\node_modules\hiredis\build\binding.sln]
The full error find in the image.
This apparently is a common error people come across as a window user.
If you are recently update your Visual studio to a new version such as 2012 and above will see similar from the above.
There are articurs on this, if you use the right search keys, here is one of them and the author explains it in details. link
three solutions:
1) npm install -g windows-build-tools stackoverflow
2) install visual studio 10 -> npm clear cache --force -> delete node_modules/ -> delete package-lock.js npm config set msvs_version 2010 -g
3) manually download the neccaries files then npm config set msvs_version -g github

Apache Cordova VS Community 2015 - Run Dependency Checker Fails

Apache Cordova Dependency Checker fails in VS Community 2015. It was previously working on this computer until I ran several VS and 3rd party tools updates. Here's what I've done to try to resolve the issue:
Installed VS / Apache Cordova (no error messages displayed) following article https://taco.visualstudio.com/en-us/docs/install-vs-tools-apache-cordova/
Run Apache Cordova Dependency Checker but VS freezes with the error message - VS 2015 has stopped working, windows will try to restart the program.
I restarted VS and cleared Cordova cache, checked environment variables (all good), then tried Apache Cordova Dependency Checker with the same freeze result.
I tried to update Apache Cordova with the fix option (no error messages) but received the same freeze results.
I completely uninstalled Apache Cordova, 3rd party tools (following article https://support.microsoft.com/en-us/kb/3016536), and VS community and then reinstalled them (no error messages) but received the same freeze results.
I installed Apache Cordova on another computer and the dependency checker phonegap app... worked. Unfortunately that's not a computer that I have access to.
What else can I do to resolve the Apache Cordova installation issue?
Thanks for any help,
Mike
Since my original post, I've had to resolve Visual Studio, Ionic, Cordova, Phonegap, plugin... environment issue several times. I've found the below works best:
Ensure platform matches plugin requirements, see platform in config.xml e.g. 6.1.1
Uninstall, reinstall latest jdk (adobe)
Clear MEF Cache - download the tool and follow instructions
Download/install latest node.js
Run the following from the command line:
Clear cache: Npm cache clean
Install latest npm: npm install -g npm
Uninstall cordova: Npm uninstall -g cordova
Reinstall cordova: Npm install –g cordova (note, this took 5+ tries to complete without errors. No other changes were made between runs. Not sure
why. Found others complaining about the same issue.)
Remove Android platform: Cordova platform remove android
Install Cordova platform add android#6.X.X (Note, as of 4/20/17 cordova and android compatibility issue. Build error - unable to find installed version of gradle. resolved by running (npm install -g cordova#6.4.0) and (cordova platform add android#6.1.2). Addt'l build errors, resolved by updating components in Android SDK Manager)
Uninstall/Reinstall plugins from the command line. For example:
cordova plugin remove phonegap-plugin-push
cordova plugin add phonegap-plugin-push variable SENDER_ID="YourID#"
npm install bower -g
Restart Visual Studio - Verify plugins were installed via config.xml
Install Ionic:
npm uninstall -g ionic
npm install -g ionic (note: to install specific version, npm install -g ionic#2.2.3)
$ ionic platform add ios
$ ionic platform add android (note: redundant, already added above)
I recommend putting as much of this as possible in a batch file with a pause between commands. Verify each command was successful, if not press ctrl+break at the pause to term the batch file early. The batch file is an easy way to restore your environment when everything breaks again. Stuff happens!
I also started using a VM (oracle virtualbox) for my development environment. That way I can backup my environment before making changes and easily restore. Don't forget to upload to GIT on a daily basis. GIT and VMs are my lifesavers.
Cool NPM commands:
npm list (lists all installed packages)
npm prune (removes packages not depended on by your project according to your package.json)
npm outdated (tells you which installed packages are outdated with respect to what is current in the npm registry but allowable by the version definition in your package.json. Make sure all up-to-date)
Please feel free to add/make suggestions to the above list.
-Mike