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
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.
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.
In Terminal of Visual Studio Code, when I try to run:
dotnet add package MicrosoftOfficeCore --version 15.0.0
I get the following error on Visual Studio Code terminal:
error: NU1100: Unable to resolve 'MicrosoftOfficeCore (>= 15.0.0)' for 'net5.0'
error: Package 'MicrosoftOfficeCore' is incompatible with 'all' frameworks in project
Do anyone have an idea?
Try clearing the NuGet cache using dotnet nuget locals all --clear, and then try to add your package.
If that doesn't work, try deleting the NuGet.config file present inside C:\Users\<username>\AppData\Roaming\NuGet directory, and then restore it using dotnet restore command. Try adding your package after this.
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'm trying to compile my C# project using the restore command:
bat "nuget.exe restore \"C:(...)\\Bin\\msbuild.exe\" mycoolproj.sln \t:Clean,Build"
And I get restore: invalid arguments error.
Then I changed to /t:Clean,Build, and I get "Unknown option 't:Clean,Build'".
Do you know what is the problem?
The /t:Clean,Build is a msbuild.exe switch and currently you can't pass switches to msbuild using nuget.exe. Alternatively because you're building your project you can tell msbuild.exe to restore those packages for you:
msbuild.exe solution.sln /t:rebuild,restore
Also in MSBuild 15.5 and later there is a /restore switch which is recommended:
msbuild.exe solution.sln /restore /t:rebuild
You can learn more about MSBuild CLI here and NuGet CLI here.