Can not create xUnit Test Project with dotnet CLI - c#

I'm trying to create a xUnit Test Project with dotnet CLI:
dotnet new xunit -o Tests
And then I get these errors:
Failed to download package 'coverlet.collector.3.1.2' from
'https://api.nuget.org/v3-flatcontainer/coverlet.collector
/3.1.2/coverlet.collector.3.1.2.nupkg'. The download of
'https://api.nuget.org/v3-flatcontainer/coverlet.collector/3.1.2/coverlet.collector.3.1.2.nupkg'
time d out because no data was received for 60000ms.
Exception of type 'System.TimeoutException' was thrown. Failed to download package 'Microsoft.CodeCoverage.17.3.2' from
'https://api.nuget.org/v3-flatcontainer/microsoft.cod
ecoverage/17.3.2/microsoft.codecoverage.17.3.2.nupkg'. The download
of
'https://api.nuget.org/v3-flatcontainer/microsoft.codecoverage/17.3.2/microsoft.codecoverage.17.3.2.n
upkg' timed out because no data was received for 60000ms.
Exception of type 'System.TimeoutException' was thrown. Failed to download package 'xunit.extensibility.core.2.4.2' from
'https://api.nuget.org/v3-flatcontainer/xunit.extens
ibility.core/2.4.2/xunit.extensibility.core.2.4.2.nupkg'. The
download of
'https://api.nuget.org/v3-flatcontainer/xunit.extensibility.core/2.4.2/xunit.extensibility.core.2.4.2
.nupkg' timed out because no data was received for 60000ms.
Exception of type 'System.TimeoutException' was thrown.
My Internet bandwidth is still good. I tried to create it with Visual Studio but still get the same error. What can I do?

Related

dotnet build/msbuild fails on GenerateResource Task with .NET 6

I try to build my project in my CI/CD pipeline with a gitlab runner, but I always end in the following error message:
C:\Program Files\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(3264,5): error MSB4216: The GenerateResource task could not be performed because MSBuild could not create a task host or connect to a task host with runtime CLR4 and architecture x86. Make sure that (1) the requested runtime and/or architecture is available on the computer and (2) the required executable file "C:\Program Files\dotnet\sdk\6.0.100\MSBuild.exe" exists and can be executed. [project_path]
C:\Program Files\dotnet\sdk\6.0.100\Microsoft.Common.CurrentVersion.targets(3286,7): error MSB4028: The output of the GenerateResource task could not be retrieved from the FilesWritten parameter. Object does not match target type. [project_path]
I´ve installed .NET6 SDK with version 6.0.100.
It seems like its trying to find the msbuild.exe and it´s not there. I´ve copied the file temporarely but this causes a endless building without result or error message.
Am I missing something? In my Visual Studio 2022 the build process is working and generating my binaries.

Nuget error when trying to publish in .Net5

When I publish in .Net5 I get the following Errors
Severity Code Description Project File Line Suppression State
Error Assets file 'C:\Users\cornelis.dejager\source\repos\Marel.MSAWebServiceAPI\Marel.MSAWebServiceAPI\obj\publish\win-x86\project.assets.json' not found. Run a NuGet package restore to generate this file. Marel.MSAWebServiceAPI 0
and
Severity Code Description Project File Line Suppression State
Error Failed to retrieve information about 'Microsoft.WindowsDesktop.App.Runtime.win-x86' from remote source 'https://api.nuget.org/v3-flatcontainer/microsoft.windowsdesktop.app.runtime.win-x86/index.json'.
An error occurred while sending the request.
The request was aborted: Could not create SSL/TLS secure channel. Marel.MSAWebServiceAPI 0
What caused it:
Not sure to be honest. After I changed code it stopped working. The project has been fine for weeks now and suddenly it changed.
I have tried
Cleaned solution
Build/Re-Build Solution
Restore The Nuget Packages
Update Visual Studio
Rebuild All projects
Delete Bin & Object folders
Update all packages
Restarting Visual Studio + Computer
Created new publishing profile
install dotnet-WindowsDesktop
Reinstall .Net5 Runtimes
Run the command:
Additional Info
It builds and run fine. Only when I publish it seems to give me an error.
I really do not why publishing isn't working. I've looked at several places but have not found a solution to it yet.
It may happen from the wrong package source,
In Visual Studio go to
Options=> Nuget Package Manager=> Package Sources
if you are using a custom source make sure you have entered the address correctly.
NuGet default source address is https://api.nuget.org/v3/index.json

Deploying To Azure throws Http Status 500 when from Command Line and works when from VS'17

I am trying to deploy to Azure using Command Line:
nuget restore MySolution.sln
msbuild MySolution.WebApi /P:DeployOnBuild=True /p:UserName='userName' /p:PassWord='pass' /p:PublishProfile=$publishProfile
the deploy works fine, no errors are thrown.
When checking the API, I get the following error :
**HTTP Error 500.0 - Internal Server Error**
* IIS received the request; however, an internal error occurred during the processing of the request. The root cause of this error depends on which module handles the request and what was happening in the worker process when this error occurred.
* IIS was not able to process configuration for the Web site or application.
When I use the VS 17 to deploy the APP using the same publish profile, I can verify that the API throws no errors. Its working fine.
Well, I checked Web.Config, App.json and buildConfig.json, they are all the same.
What else could cause this kind of situation ?
I was missing an Output Path.
msbuild MySolution.WebApi /t:Build /p:Configuration='MyConfig' /p:OutputPath=$outputPath /P:DeployOnBuild=True /p:UserName='userName' /p:PassWord='pass' /p:PublishProfile=$publishProfile

How to Run Selenium UI tests in azure pipeline for c#. OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL

I am trying to run selenium UI tests through vsts release pipeline usingVisual Studio Test tasks from vsts release. My tests are getting recognized but not getting executed. getting same error for all tests.
I have tried updating the chrome drive used the old chrome driver still no luck. Initially I was using the chromedrive.exe file in my sln but then I removed that and add a nuget reference form Selenium.Chrome.Webdriver 2.45. tests are running fine on my local machine but when I deploy on vsts agent server I am getting an error
this the error I am getting in my VsTest log
Starting ChromeDriver 2.45.615291 (ec3682e3c9061c10f26ea9e5cdcf3c53f3f74387) on port 4620
Only local connections are allowed.
Failed _MenuConfirmation
Error Message:
OpenQA.Selenium.WebDriverException : The HTTP request to the remote WebDriver server for URL http://localhost:4580/session/1315de45cb967b450b25cef659f6/window/current/size timed out after 60 seconds.
----> System.Net.WebException : The operation has timed out
Stack Trace:
at
OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.DriverServiceCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteWindow.set_Size(Size value)
at abc.AutomatedTests.BaseTestingClass.CommonInit() in D:\teams\build4\_work\1\s\src\abc.AutomatedTests\BaseTestingClass.cs:line 43
--WebException
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
In my basetestingclass.cs I have code to launch the browser and set its size.
[SetUp]
public void CommonInit()
{
driver = new SeleniumDriver (browser).getdriver();
driver.Navigate().GoToUrl(url);
driver.Manage().Window.Size = new Size { Width = 1920, Height = 1080 };
//driver.Manage().Window.Maximize();
}
In my prior tries I was getting same error for Maximize() code.
This is was added in mu csproj after the nuget addition
<Import Project="..\packages\Selenium.Chrome.WebDriver.2.45\build\Selenium.Chrome.WebDriver.targets" Condition="Exists('..\packages\Selenium.Chrome.WebDriver.2.45\build\Selenium.Chrome.WebDriver.targets')" />
and this in packages.
<package id="Selenium.Chrome.WebDriver" version="2.45" targetFramework="net452" />
I want to Run the selenium tests In my VSTS pipeline using the Visual Studio Test. Also I have Visual Studio Test Platform Installer task prior to test execution task in my pipeline and my tests are getting recognized successfully.
I tried most of the available solution but still the same error. hence asking again.
The error message indicates that the agent you are running the UI tests on can't reach the URL you've specified.
Are you using a hosted agent in the release pipeline in AzDO? If so, it won't have line of sight to your localhost URL. Check that by changing your URL to google.com or bing.com and it should be able to run the test successfully.
Install a self-hosted agent on your machine instead: https://learn.microsoft.com/en-us/azure/devops/pipelines/agents/agents?view=azure-devops#install
Or follow this: https://www.azuredevopslabs.com/labs/vstsextend/selenium/.
You'll want to make sure that the appropriate NuGet packages for Selenium are also getting restored but I don't think that's specifically related to this error you're getting.

Lambda An error occurred while attempting to execute your code

I am using AWS Lambda toolkit for C#. When I am publishing AWS Lambda directly it is working fine on AWS. But when I am trying to make a zip file by using publish and then making the zip of all DLL under bin\Release\netcoreapp1.0. and trying to run.
Then it is giving an error:
{
"errorType": "LambdaException",
"errorMessage": "An error occurred while attempting to execute your code."
}
In configuration Handler name is correct.
What can be the issue?
Have you tried packing the zip using the dotnet cli command?
Try this in your project folder: dotnet lambda package -o .\lambda.zip
It should create a lambda.zip file which you can try to upload.

Categories