I am trying to run a xunit test project. I've followed the below steps to do that so, but however I've been getting "No executable found matching command dotnet-test-xunit" error.
Steps:
1. Created a folder named "Tests" in the local drive.
2. Keeping the "Tests" folder as current directory in the command line, I ran the following commands:
a) dotnet new --type xunittest
b) dotnet restore
c) dotnet test
3. Finally, while executing the "dotnet test" command, I got "dotnet-test-xunit" not found.
My .NET(dotnet) version: 1.0.0-preview2-003131
Also, when I searched for the "dotnet-test-xunit" package in the nuget repository (https://www.nuget.org/packages?q=dotnet-test-xunit), it is not found.
Can anyone guide me through this ? Thanks in advance :)
The dotnet-test-xunit package has been unlisted.
.NET Core projects that are project.json-based are no longer supported (preview2 and earlier versions).
Newer versions of .NET Core use the xunit package.
Related
We have Xamarin.Forms solution with iOS and UWP projects. We use Azure pipelines to build the iOS project. Until yesterday everything was working fine.
Now the build fails at the NuGet Restore step with the error:
##[error]The nuget command failed with exit code(1) and error(/Users/runner/work/1/s/"MyProjectName.UWP".csproj : error MSB4057: The target "_IsProjectRestoreSupported" does not exist in the project.
We can see that the problem occurs when trying to restore NuGet packages for the UWP project on the Mac OS build host.
Image: macOS-11
Workaround will be to exclude it from the solution, but we are using it for testing purposes and this is not a good option for us.
We had the same problem yesterday for our iOS (macos-11) and Android (macos-10.15) Pipelines.
The issue 21180 for mono seems to be the root cause, which is also referenced in a pull request to update the mono version for MacOs virtual environments. Regarding to this workflow test we gave msbuild a chance, and it works.
Solution:
Instead of NuGet restore we use directly MSBuild.
- task: MSBuild#1
inputs:
solution: 'App.sln'
configuration: 'Release'
msbuildArguments: /t:restore
Looking at the log file, MSBuild ignores the UWP project. That is the behavior that NuGet had with the older mono version 6.12.0.125. Ignoring the UWP-Project is no problem, because it can only be build on windows environments.
Project "/Users/runner/work/1/s/App.sln" on node 1 (Restore target(s)).
ValidateSolutionConfiguration:
Building solution configuration "Release|Any CPU".
/Library/Frameworks/Mono.framework/Versions/6.12.0/lib/mono/msbuild/Current/bin/NuGet.targets(315,5): warning : Skipping restore for project '/Users/runner/work/1/s/App/App.UWP/App.UWP.csproj'. The project file may be invalid or missing targets required for restore. [/Users/runner/work/1/s/App.sln]
Some additional information:
The NuGet restore task uses msbuild to find all referenced packages. If that fails, it will use the packages.config file as fallback, the pipeline step will not fail.
Instead we got an error in the build steps for Android & iOS:
error NETSDK1004: Assets file
'/Users/runner/work/1/s/../obj/project.assets.json' not found. Run a
NuGet package restore to generate this file.
Updated Answer
This can be resolved using MSBuild task instead, as the collogues mentioned below.
However, in my case this still lead to the same error. After investigating the pipeline. The root cause has been identified:
Both in MSBuild#1 and XamariniOS#2 tasks
you should target the specific iOS Project and not the solution file, like so:
"
- task: MSBuild#1
inputs:
solution: 'PathToIosProject/myproject.iOS.csproj'
configuration: '$(BuildConfiguration)'
msbuildArguments: /t:restore
" - task: XamariniOS#2
inputs:
solutionFile: PathToIosProject/myproject.iOS.csproj'
configuration: '$(BuildConfiguration)'
packageApp: true
signingIdentity: $(APPLE_CERTIFICATE_SIGNING_IDENTITY)
Old Answer
We have managed to resolve the issue. The root cause of it seems to be an update to the mono framework in the MacOS pipeline build agent.
In order to fix it, we need a script for downloading and installing an older version of the mono framework as a first step of the build pipeline like so:
link to the pipeline tasks photo
This is the code of the bash scrip used in the task:
#!/bin/bash
set -ex
MONO_MACOS_PKG_DOWNLOAD_URL='https://download.mono-project.com/archive/6.12.0/macos-10-universal/MonoFramework-MDK-6.12.0.100.macos10.xamarin.universal.pkg'
mkdir -p /tmp/mono-install
cd /tmp/mono-install
mono --version
wget -q -O ./mono-installer.pkg "$MONO_MACOS_PKG_DOWNLOAD_URL"
sudo installer -pkg ./mono-installer.pkg -target /
mono --version
ls -alh /Library/Frameworks/Mono.framework/Versions/Current
I am working on an ASP.NET Web API 2 project with .NET target framework 4.6.1. I am trying to setup github workflow for my repo. When the dotnet restore command is run, it throws an error like below.
I am getting the same error if I run the same command in from command prompt inside my project. Also if I run dotnet build, it shows below error.
The project builds fine from Visual Studio but not working from command line or github workflow yml. Can anyone please point me on what am I missing?
The project builds fine from Visual Studio but not working from command line
Check which sln file Visual Studio is using to build your project.
Since I don't see any sln/csproj in your GitHub repository, it is also possible that you have a .gitignore which would prevent adding those in the first place.
DOTNET Restore does not support pacakges.config https://learn.microsoft.com/en-us/dotnet/core/tools/dotnet-restore
So you have to move the nuget package references to csproj file itself
Here is a great comment on how to do that https://stackoverflow.com/a/65701746/8318698
Note: check that if multiple projectGuid is there on csproj at the end of the steps
After that you will be able to use dotnet restore without a hitch.
I have visual studio 2019 and i created a new asp.net core 2.2 project. now i am following these steps Configure Microsoft Account Authentication to enable external login to our web application. but when i run this command:-
dotnet add package
Microsoft.AspNetCore.Authentication.MicrosoftAccount
i got this error:-
PM> dotnet add package
Microsoft.AspNetCore.Authentication.MicrosoftAccount dotnet : Could
not find any project in C:\Users\*****\source\repos\MSlogintest\. At
line:1 char:1
+ dotnet add package Microsoft.AspNetCore.Authentication.MicrosoftAccount
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (Could not find ...\MSlogintest`.:String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError Usage: dotnet add package [options]
Arguments: The project file to operate on. If a
file is not specified, the command will search the current directory
for one. The package reference to add.
Options: -h, --help Show command line help.
-v, --version The version of the package to add. -f, --framework Add the reference only when targeting a specific framework. -n, --no-restore
Add the reference without performing restore preview and compatibility
check. -s, --source The NuGet package source
to use during the restore. --package-directory The
directory to restore packages to. --interactive
Allows the command to stop and wait for user input or action (for
example to complete authentication).
as follow:-
and when i access the folder, i found that there is a VS project folders, as follow:-
so why the error is saying that it can not find any project?
can anyone advice on this error please?
Thanks
I encountered the same issue and found the fix. First of all, read the error message completely and carefully. It says:
"Could not find any project ...."
Which means it was expecting the project information. If you further watch the message closely, it has mentioned the correct usage of this command i.e.
Usage: dotnet add <PROJECT> package [options] <PACKAGE_NAME>
In the argument, enter your project name and run it again. This time, you should see the success message similar to:
info : Adding PackageReference for package 'Microsoft.xxxxxxxx.xxxxxxxx' into project 'C:\Users\xxx\source\repos\ProjectFolder\xxxxxxxx.csproj'.
Got this working on powershell (no IDE). The solution was somewhere hidden in the comments but here is the easy one:
dotnet add <project> package <packageName>
In this case I believe it would be:
dotnet add ContosoUniversity package Microsoft.AspNetCore.Authentication.MicrosoftAccount
cd into the particular project you want to add the package to and type your dotnet command again
> cd project Directory
> dotnet add package Microsoft.AspNetCore.Authentication.MicrosoftAccount
Had the same problem, when i was fiddling around with the nuget commandline it at some point proposed i should retry with elevated privileges.
Specifically i tried manually pointing it one level deeper in the folder structure. (As suggested by DavidG)
I thought: okay, weird, but i am out of good ideas, so lets try that one.
Restarted as administrator, worked.
And by it worked i mean it just worked, no manual fiddling involved. I just used the graphical package manager option that just somehow became available.
So my best guess is i somehow messed up something when installing visual studio. Because i already tried just creating a new project.
Nuget option as admin
You may be clicking on the wrong tab on the nuget site. Make sure you select Package Manager tab. The error you get happens when you click on the .net cli tab and use it in the package manager console window.
Try this in your command terminal, you should into a directory project:
dotnet add package <package.name>
This command is for .NET core. I used it for an old project because it's the first one shown on nuget.org.
The old command should be like this:
Install-Package [package name]
I've create a simple console application along with a simple docfx project. When I run the DocFX command to generate the documentation I get the following metadata warning and becuasue the warning leads to the documentation not being generated.
[18-06-05 05:52:41.715]Warning:MetadataCommand.ExtractMetadataWorkspace failed with: [Failure] Msbuild failed when processing the file 'E:\Files\tmp\docx\docfx_project\src\src.csproj' with message: C:\Program Files\dotnet\sdk\2.1.300\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets: (198, 5): Error loading lock file 'E:\Files\tmp\docx\docfx_project\src\obj\project.assets.json' : Object reference not set to an instance of an object.
later in the output you see
[18-06-05 05:52:42.467]Warning:[MetadataCommand.ExtractMetadata]No metadata is generated for src.
Anyone else run into this problem? How can I get metadata to generate?
To recreate the project is pretty simple:
goto dotnet cli tools command line
docfx init
cd src
dotnet new console
cd ..
docfx
I have installed and using the dotnet sdk 2.1.300
With .net 2.1 there is a breaking change in the use of tools, which are now installed and used globally like this:
dotnet watch
dotnet user-secrets
dotnet sql-cache
dotnet dev-certs
The developers of docfx are currently working on a version which supports .net 2.1 (docfx v3): https://github.com/dotnet/docfx/pull/2829
Here you can see the current status of implemenation: https://github.com/dotnet/docfx/projects/1
So the answer to your question is: as of yet you can't use docfx with .net 2.1
Running Cake Build script on my local machine works fine but when same script is run on TeamCity, the following error appears: Nuspec file does not exist in package.
Any idea what could have caused this error?
I spent two days due to this error
On dotnet build --configuration Release in TeamCity PowerShell, always got this error
error NU5000: Nuspec file does not exist in package
After deleting this folder, everything worked C:/Users/teamcity_user/.nuget
I add an additional step on top of my build steps which is a command line custom script
dotnet nuget locals --clear all