I am using asp.net core 2.1 with visual studio code or rider in mac. I already have a 2.1 sdk install on mac, while using the below command
dotnet-ef database update --project XXXX.XXXX
I get an exception as
zsh: command not found: dotnet-ef
Using the command
dotnet tool install --global dotnet-ef
getting an exception as Tool 'dotnet-ef' is already installed.
Then using this command dotnet tool restore
error NU3037: Package 'dotnet-ef 3.1.1' from source 'https://api.nuget.org/v3/index.json': The repository countersignature validity period has expired.
Package "dotnet-ef" failed to restore, due to Microsoft.DotNet.ToolPackage.ToolPackageException: The tool package could not be restored.
For mac I need to export the below path
export PATH="$PATH:$HOME/.dotnet/tools/"
Yes, give an example of the error:
$ dotnet ef
Could not execute because the specified command or file was not found.
Possible reasons for this include:
* You misspelled a built-in dotnet command.
* You intended to execute a .NET Core program, but dotnet-ef does not exist.
* You intended to run a global tool, but a dotnet-prefixed executable with this name could not be found on the PATH.
The second and third refer to dotnet trying to find a dotnet-ef command but it cannot find it. As the third point said, dotnet-ef is not on your way.
This is what the documentation says:
Global tools can be installed in the default directory or in a specific location. The default directory is:
OS Path
Linux/macOS $HOME/.dotnet/tools
Windows %USERPROFILE%\.dotnet\tools
So, you should add $HOME/.dotnet/tools/ to your $PATH.
For Linux and macOS, add a line to the shell configuration:
bash/ zsh:
export PATH="$PATH:$HOME/.dotnet/tools/"
When you start a new shell/terminal (or next time you log in) dotnet ef should work.
For Windows:
You need to add %USERPROFILE%.dotnet\tools to PATH.
I am using asp.net core 6.0
zhengguo#macdeMac-min % echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
The PATH has already exist ~/.dotnet/tools
When I use dotnet aspnet-codegenerator, it works. dotnet-aspnet-codegenerator not work.
Related
We are using Azure DevOps pipelines. We have a step that publishes the our private nuget package to the Azure Artifacts. However, the build breaks at other steps because the nuget package (that was published on previous steps) is not found. The strange thing is that after the package is published, I can see it in the package-manager console or on Visual Studio and even in the Artifacts in Azure DevOps. But for some reason, the pipeline doesn't find the package. After 30-50min, I re-run the pipeline and then it finds the package.
What could be happening to take so long time for the pipeline to find the my package?
Edit 1:
This is my yaml for the step with error
- script: |
pwd && ls -la
dotnet restore "$(solution_path)" $(nuget_args)
dotnet publish -c Release -o $(System.DefaultWorkingDirectory)/bin "$(main_project_path)"
mkdir artifact
cp -r $(System.DefaultWorkingDirectory)/bin artifact/bin
displayName: Build Application
The error is:
/data/vstsagent/user/389/s/src/MyProject.csproj
: error NU1102: Unable to find package MyPackage with
version (>= 2.1.0) [/data/vstsagent/user/389/s/src/MySolution.sln]
/data/vstsagent/user/389/s/src/MyProject.csproj
: error NU1102: - Found 28 version(s) in MyPrivateRepository [ Nearest
version: 2.1.0-preview.6 ]
[/data/vstsagent/user/389/s/src/MySolution.sln]
It is not clear what feed is used by dotnet restore command.
Confirm that you have configured your custom nuget feed in nuget.config and using it.
Try adding "--verbose" switch in dotnet restore command and check if your feed is used for restoring packages.
Use the --no-cache option so dotnet restore doesn't use the local cache.
When I trying to add Nuget Packages by Nuget gallery extension from VS Code. It doesn't install the NuGet package.
Executing task: dotnet add /home/[user]/Public/Projects/yogihosting.com/Identity/Identity/Identity.csproj package Microsoft.AspNetCore.Identity.EntityFrameworkCore -v 5.0.6 -s https://api.nuget.org/v3/index.json <
Determining projects to restore...
Writing /tmp/tmpIIHQRz.tmp
info : Adding PackageReference for package 'Microsoft.AspNetCore.Identity.EntityFrameworkCore' into project '/home/[user]/Public/Projects/yogihosting.com/Identity/Identity/Identity.csproj'.
info : Restoring packages for /home/[user]/Public/Projects/yogihosting.com/Identity/Identity/Identity.csproj...
error: Unable to load the service index for source https://api.nuget.org/v3/index.json.
error: The SSL connection could not be established, see inner exception.
error: The remote certificate is invalid because of errors in the certificate chain: UntrustedRoot
Usage: NuGet.CommandLine.XPlat.dll package add [options]
Options:
-h|--help Show help information
--force-english-output Forces the application to run using an invariant, English-based culture.
--package Id of the package to be added.
--version Version of the package to be added.
-d|--dg-file Path to the dependency graph file to be used to restore preview and compatibility check.
-p|--project Path to the project file.
-f|--framework Frameworks for which the package reference should be added.
-n|--no-restore Do not perform restore preview and compatibility check. The added package reference will be unconditional.
-s|--source Specifies NuGet package sources to use during the restore.
--package-directory Directory to restore packages in.
--interactive Allow the command to block and require manual action for operations like authentication.
--prerelease Allows prerelease packages to be installed.
The terminal process "/bin/bash '-c', 'dotnet add /home/[user]/Public/Projects/yogihosting.com/Identity/Identity/Identity.csproj package Microsoft.AspNetCore.Identity.EntityFrameworkCore -v 5.0.6 -s https://api.nuget.org/v3/index.json'" terminated with exit code: 1.
Terminal will be reused by tasks, press any key to close it.
How can I get rid of this problem?
https://api.nuget.org/v3/index.json shows:#
Note: I'm using Ubuntu.
We may solve this issue by one of following process.
copy project to another folder or create new project to another destination.
It may cause, our file or folder is corrupted.
Reinstalling our software(s) like IDE or dotnet or both.
It may cause not to be installed correctly.
The final is so funny. Re-install your OS and then other softwares.
I am unable to publish my .net function app. I am using the below configuration and settings:
.net 5 SDK Version: 5.0.300
Microsoft.Azure.Functions.Worker 1.2.0
Microsoft.Azure.Functions.Worker.Core 1.1.0
Getting below error:
Metadata generation failed. Exit code: '-532462766' Error: 'Error generating extension metadata: System.IO.DirectoryNotFoundException: The path PATH\bin\Release\net5.0\publish\bin does not exist. Unable to generate Azure Functions extensions metadata file.
The problem lies with the .targets file of Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator, it sets the _FunctionsExtensionsDir to the publish target directory + 'bin'
So if you publish to project-path\bin\release\net5.0\publish, it's looking for published output in project-path\bin\release\net5.0\publish\bin - you can prove this by doing a replace all in the .targets file replacing ')bin' with ')' and watching it run as expected.
A quick and dirty solution is to build with the -o flag set to where the metadata generator will expect the output to be, e.g.
dotnet build yourproject.csproj --framework net5.0 -c release -o c:/temp/output/bin -v d
dotnet publish yourproject.csproj --framework net5.0 -c release -o c:/temp/output -v d
I'm currently looking into a less hacky way of achieving this, and will post if/when I figure it out.
This looks like a bug in Visual Studio 2019.
Suggestion:
Record your current version, you can raise a support ticket to confirm with the official.
Upgrade your vs2019 to the latest version and try to publish again.
At the moment I have a visual studio project and I use the docfx.console nuget package to build the documentation, and everything works fine and as expected... on windows. The point is now I want to make a docker image based on mcr.microsoft.com/dotnet/core/sdk:3.1 which is based on a linux image. And compiling in this docker image running the command:
dotnet publish -c Release -o out
Gives the following error
> [build 9/9] RUN dotnet publish -c Release -o out:
#22 1.080 Microsoft (R) Build Engine version 16.0.450+ga8dc7f1d34 for .NET Core
#22 1.080 Copyright (C) Microsoft Corporation. All rights reserved.
#22 1.080
#22 2.852 Restore completed in 215.94 ms for /app/Documentation/Documentation.csproj.
#22 6.299 Documentation -> /app/Documentation/bin/Release/netcoreapp2.1/Documentation.dll
#22 6.402 /bin/sh: 2: /tmp/tmpbd72ebbe5e6b49c1b3244f1f50c8b57a.exec.cmd: /root/.nuget/packages/docfx.console/2.48.1/build/../tools/docfx.exe: Exec format error
#22 6.407 /root/.nuget/packages/docfx.console/2.48.1/build/docfx.console.targets(57,5): error MSB3073: The command ""/root/.nuget/packages/docfx.console/2.48.1/build/../tools/docfx.exe" "/app/Documentation/docfx.json" -o "" -l "log.txt" --logLevel "Verbose"" exited with code 2. [/app/Documentation/Documentation.csproj]
I already did some prodding around and I believe I have the issue mostly solved. Running file on console.exe shows that this is a PE32 executable (console) Intel 80386 Mono/.Net assembly, for MS Windows. And these kind of files should not be executed on linux using sh but with mono. And indeed running:
mono docfx.exe "/app/Documentation/docfx.json" -o "" -l "log.txt" --logLevel "Verbose"
builds the documentation just fine as expected. At this point of course I have a bunch of workarounds to get the documentation building correctly, just remove docfx.console form the csproj and build it manualy from the command line using a docker command.
But the question is, can I also use the nuget package on linux by changing how the docfx.exe command is run by the nuget package? Or is this only possible by actually fixing this in docfx.console?
p.s. in case it matters, the version of docfx.console that I am using is the most recent one available at the time of writing, namely 2.48.1
But the question is, can I also use the nuget package on linux by changing how the docfx.exe command is run by the nuget package? Or is this only possible by actually fixing this in docfx.console?
Create script docfx that runs docfx.exe using Mono, e.g., like this (assuming docfx.exe is located in /opt/docfx/docfx.exe):
echo '#!/bin/bash\nmono /opt/docfx/docfx.exe $#' > /usr/bin/docfx && chmod +x /usr/bin/docfx
Then, pass MSBuild parameter BuildDocToolPath with path to that script, e.g., like this:
dotnet publish -c Release -o out -p:BuildDocToolPath=/usr/bin/docfx
docfx.console will than use this path to execute DocFX. I think the property BuildDocToolPath isn't documented anywhere, but you can see it in source code.
I have the following travis file:
language: csharp
solution: src/LaraUI.sln
mono: none
dotnet: 3.0.100
before_install:
- sudo apt install nuget
install:
- nuget restore src/LaraUI.sln
script:
- msbuild /p:Configuration=Debug src/LaraUI.sln
- dotnet test src/Test/Tests.csproj
This gives an error saying that msbuild was not found:
msbuild: command not found
All the examples I see do not need to install anything, and msbuild/nuget just work. If I remove the line to install nuget, then I get a similar error of nuget not found.
Is there something I am missing in order to execute msbuild? Is there a way to install it?
The repository is here
You should try to use dotnet build instead of msbuild. It should do the same thing. Here https://learn.microsoft.com/de-de/dotnet/core/tools/dotnet-build