I'm having trouble debugging Xunit unittests in .NET6 running on Ubuntu 20.04 in VSCode (1.66.2). These run in VisualStudio and VSCode in Windows. I can run (not debug) the tests in Linux from the CLI or the .NET Core Test Explorer extension.
If I try to debug the unittest with the context menu or the little magic command attribute that is placed above the unittest method declaration, I get an error:
Failed to start debugger:
"System.InvalidOperationException: The debugger could not be started
at OmniSharp.DotNetTest.Services.DebugTestService.Handle
(OmniSharp.DotNetTest.Models.DebugTestGetStartInfoRequest request) [0x00050] in <9d87b466e5a04dffb95becc0b4dfd560>:0
at OmniSharp.Endpoint.Exports.RequestHandlerExportHandler`2[TRequest,TResponse].Handle (TRequest request) [0x00000] in <3d93fabea6954f4ba147450b0cf4332a>:0
at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler`2[TRequest,TResponse][] handlers, TRequest request) [0x00022] in <3d93fabea6954f4ba147450b0cf4332a>:0
at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <3d93fabea6954f4ba147450b0cf4332a>:0
at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <3d93fabea6954f4ba147450b0cf4332a>:0
at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000f3] in <2584067dfcea42a69c19a025cfbc4799>:0 "
I also see this in the OUTPUT pane:
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error MSB3883: Unexpected exception: [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : DirectoryNotFoundException: Could not find a part of the path '/home/danielp/Source/Experiments/LibAndTest/Library/bin/Debug/net6.0/ref/Library.dll'. [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirectory, Func`2 errorRewriter) [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode) [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize) [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at System.IO.FileSystem.CopyFile(String sourceFullPath, String destFullPath, Boolean overwrite) [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite) [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : at Microsoft.CodeAnalysis.BuildTasks.CopyRefAssembly.Copy() [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
/usr/share/dotnet/sdk/6.0.202/Microsoft.Common.CurrentVersion.targets(4650,5): error : [/home/danielp/Source/Experiments/LibAndTest/Library/Library.csproj]
What I find interesting here is that it keeps looking for referenced dlls in ...Debug/net6.0/ref/Library.dll' and there is no build output binary placed there much less a folder called ref.
For now, I can debug w/ a console app, but it sure seems strange that this works so well in Windows but not Linux. However, now that I say that out loud: it seems like it shouldn't be that surprising.
Lastly, I did try debugging mstest unittests w/ the same results.
I figured it out! But only because I found this other answered question:
Cannot Run or Debug C# tests with CodeLens in VSCode
Because I'm running .NET 6, the Omnisharp extension needed a settings change:
Open your VSCode extensions w/ the icon on the left
Search for Omnisharp in the text box
Click the gear icon and choose Extension Settings from the resulting context menu
Up top in the search bar that is revealed in the settings page, append (w/ a space) modern so that the search bar contains #ext:ms-dotnettools.csharp modern
You will see a checkbox labeled Omnisharp: Use Modern Net.
Make sure this is checked.
I had to restart VSCode and allow the extension to do a download
After that it works.
Related
today i am getting error on publish tasks of .netcore app 3.1 in Azure. Publish error, after getting search on google I have added another tasks "Use .Net Core sdk 3.1" by following this link web URL and thinks it will done but running same error, the Agent i am using is "Window 2019" please find the below log, and tell me what i am doing wrong.
2020-01-10T07:23:54.1832757Z ##[section]Starting: Publish
2020-01-10T07:23:54.1955402Z ==============================================================================
2020-01-10T07:23:54.1955499Z Task : .NET Core
2020-01-10T07:23:54.1955578Z Description : Build, test, package, or publish a dotnet application, or run a custom dotnet command
2020-01-10T07:23:54.1955801Z Version : 2.162.0
2020-01-10T07:23:54.1955866Z Author : Microsoft Corporation
2020-01-10T07:23:54.1955930Z Help : https://learn.microsoft.com/azure/devops/pipelines/tasks/build/dotnet-core-cli
2020-01-10T07:23:54.1956023Z ==============================================================================
2020-01-10T07:23:54.9006939Z [command]C:\windows\system32\chcp.com 65001
2020-01-10T07:23:54.9110635Z Active code page: 65001
2020-01-10T07:23:55.3752628Z [command]C:\hostedtoolcache\windows\dotnet\dotnet.exe publish d:\a\8\s\RINMVC.csproj --configuration $(BuildConfiguration) --output d:\a\8\a\s
2020-01-10T07:23:55.6992883Z Microsoft (R) Build Engine version 16.4.0+e901037fe for .NET Core
2020-01-10T07:23:55.6993590Z Copyright (C) Microsoft Corporation. All rights reserved.
2020-01-10T07:23:55.6993774Z
2020-01-10T07:23:56.7768936Z d:\a\8\s\RINMVC.csproj : warning NU1701: Package 'System.Net.Http.Formatting.Extension 5.2.3' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.
2020-01-10T07:23:56.7778950Z Restore completed in 48.65 ms for d:\a\8\s\RINMVC.csproj.
2020-01-10T07:23:57.1151368Z d:\a\8\s\RINMVC.csproj : warning NU1701: Package 'System.Net.Http.Formatting.Extension 5.2.3' was restored using '.NETFramework,Version=v4.6.1, .NETFramework,Version=v4.6.2, .NETFramework,Version=v4.7, .NETFramework,Version=v4.7.1, .NETFramework,Version=v4.7.2, .NETFramework,Version=v4.8' instead of the project target framework '.NETCoreApp,Version=v3.1'. This package may not be fully compatible with your project.
2020-01-10T07:23:57.5687153Z C:\hostedtoolcache\windows\dotnet\sdk\3.1.100\Roslyn\Microsoft.CSharp.Core.targets(59,5): warning MSB3052: The parameter to the compiler is invalid, '/define:$(BUILDCONFIGURATION)' will be ignored. [d:\a\8\s\RINMVC.csproj]
2020-01-10T07:23:58.4874838Z Controllers\CompaniesController.cs(18,46): warning CS0169: The field 'CompaniesController.categoryViewModel' is never used [d:\a\8\s\RINMVC.csproj]
2020-01-10T07:24:01.5598101Z Could not find a part of the path 'd:\a\8\s\obj\$(BuildConfiguration)\netcoreapp3.1\Razor\Views\Cases\Add.cshtml.g.cs'.
2020-01-10T07:24:01.5599371Z at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
2020-01-10T07:24:01.5602238Z at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
2020-01-10T07:24:01.5602742Z at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
2020-01-10T07:24:01.5624368Z at System.IO.StreamWriter.ValidateArgsAndOpenPath(String path, Boolean append, Encoding encoding, Int32 bufferSize)
2020-01-10T07:24:01.5624829Z at System.IO.StreamWriter..ctor(String path)
2020-01-10T07:24:01.5625325Z at System.IO.File.WriteAllText(String path, String contents)
2020-01-10T07:24:01.5625688Z at Microsoft.AspNetCore.Razor.Tools.GenerateCommand.ExecuteCore(RazorConfiguration configuration, String projectDirectory, String tagHelperManifest, SourceItem[] sourceItems)
2020-01-10T07:24:01.5626021Z at Microsoft.AspNetCore.Razor.Tools.GenerateCommand.ExecuteCoreAsync()
2020-01-10T07:24:01.5626352Z at Microsoft.AspNetCore.Razor.Tools.CommandBase.ExecuteAsync()
2020-01-10T07:24:01.5731592Z C:\hostedtoolcache\windows\dotnet\sdk\3.1.100\Sdks\Microsoft.NET.Sdk.Razor\build\netstandard2.0\Microsoft.NET.Sdk.Razor.CodeGeneration.targets(150,5): error : rzc generate exited with code 1. [d:\a\8\s\RINMVC.csproj]
2020-01-10T07:24:01.6262880Z ##[error]Error: The process 'C:\hostedtoolcache\windows\dotnet\dotnet.exe' failed with exit code 1
2020-01-10T07:24:01.6277867Z ##[warning]Info: Azure Pipelines hosted agents have been updated to contain .Net Core 3.x SDK/Runtime along with 2.2 & 2.1. Unless you have locked down a SDK version for your project(s), 3.x SDK might be picked up which might have breaking behavior as compared to previous versions.
Some commonly encountered changes are:
If you're using `Publish` command with -o or --Output argument, you will see that the output folder is now being created at root directory rather than Project File's directory. To learn about more such changes and troubleshoot, refer here: https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/build/dotnet-core-cli?view=azure-devops#troubleshooting
2020-01-10T07:24:01.6278863Z ##[error]Dotnet command failed with non-zero exit code on the following projects : d:\a\8\s\RINMVC.csproj
2020-01-10T07:24:01.6298381Z ##[section]Finishing: Publish
Yes I have resolved the issue as per #silent question that
Did you declare the variable BuildConfiguration ?
Due to testing purpose unfortunately I have deleted the variable (BuildConfiguration) into build definition under Variables section, so when i added the variable and save the definition its works as expected.
Thanks for the feedback #slient
I get the below exception when debugging an xunit test using .net MVC 5, .net framework version 4.6.2 and visual studio 2019.
**
System.IO.FileNotFoundException HResult=0x80070002 Message=Could
not find file 'Could not find file
'..\bin\Debug\TestProj.UnitTests.xunit.runner.json'. Source=mscorlib
StackTrace: at System.IO.__Error.WinIOError(Int32 errorCode, String
maybeFullPath) This exception was originally thrown at this call
stack: System.IO.__Error.WinIOError(int, string)
**
Please see the below images.
for me adding this file was all it took `{projectname}.
and in the file content look like this
{
"$schema": "https://xunit.net/schema/current/xunit.runner.schema.json"
}
also don't forget to set the file to copy on build.
based on documentation found here
I have followed this tutorial on getting angular and ASP.NET Core running together. The initial build worked fine but after updating angular packages I am receiving the following error on startup of the application(I also had to reinstall nodejs in the process, not sure if this is related):
The error is on the following line:
app.UseWebpackDevMiddleware(new WebpackDevMiddlewareOptions {
HotModuleReplacement = true
});
The error itself does not provide me with any usefull information to track down the issue.
I get a:
System.AggregateException => Count = error CS0103: The name
'InnerExceptionCount' does not exist in the current context
Under InnerExceptions it lists the following error:
System.ComponentModel.Win32Exception: The system cannot find the file
specified at System.Diagnostics.Process.StartCore(ProcessStartInfo
startInfo) at System.Diagnostics.Process.Start() at
System.Diagnostics.Process.Start(ProcessStartInfo startInfo) at
Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance.LaunchNodeProcess(ProcessStartInfo
startInfo) at
Microsoft.AspNetCore.NodeServices.HostingModels.OutOfProcessNodeInstance..ctor(String
entryPointScript, String projectPath, String[] watchFileExtensions,
String commandLineArguments, ILogger nodeOutputLogger, IDictionary2
environmentVars, Int32 invocationTimeoutMilliseconds, Boolean
launchWithDebugging, Int32 debuggingPort) at
Microsoft.AspNetCore.NodeServices.HostingModels.HttpNodeInstance..ctor(String
projectPath, String[] watchFileExtensions, ILogger
nodeInstanceOutputLogger, IDictionary2 environmentVars, Int32
invocationTimeoutMilliseconds, Boolean launchWithDebugging, Int32
debuggingPort, Int32 port) at
Microsoft.AspNetCore.NodeServices.NodeServicesFactory.CreateNodeInstance(NodeServicesOptions
options) at
Microsoft.AspNetCore.NodeServices.NodeServicesFactory.<>c__DisplayClass0_0.b__0()
at
Microsoft.AspNetCore.NodeServices.NodeServicesImpl.CreateNewNodeInstance()
at
Microsoft.AspNetCore.NodeServices.NodeServicesImpl.GetOrCreateCurrentNodeInstance()
at
Microsoft.AspNetCore.NodeServices.NodeServicesImpl.d__10`1.MoveNext()}
If someone can point me in the direction to get more information from the Error would be helpful.
It looks like it is unable to find node.exe. I saw the same error after installing Node for the first time. It was because installing Node modified the system Path and the new Path wasn't getting picked up by IIS. I had to reboot my server and it was then able to find the node exe.
Check if you have the latest NPM installed. This solved my problem.
OK, I have a similar problem as Download ClickOnce fails from setup.exe and Download ClickOnce fails from setup.exe , where I have deployed a ClickOnce installer for a desktop app I am selling.
Different than those examples, I am using Visual Studio 2012 (Pro Version). Using .Net 3.5. I am deploying on a hosted LINUX machine. It worked for me and other people running Windows 7 & 8, possibly earlier versions of Widnows. Then after running a few tests in Debug mode, I built and deployed in Release mode. Now, the auto-installer breaks when it gets to the spot where it wants to download the .application file. Here's the log file.
The following properties have been set:
Property: [AdminUser] = true {boolean}
Property: [InstallMode] = HomeSite {string}
Property: [NTProductType] = 1 {int}
Property: [ProcessorArchitecture] = AMD64 {string}
Property: [VersionNT] = 6.2.0 {version}
Running checks for package 'Microsoft Visual Basic PowerPacks 10.0', phase BuildList
Attempting to find 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=YADDAYADDA' in the Global Assembly Cache
AssemblyCheck: Error querying assembly info: -2147024894
Attempting to find 'Microsoft.VisualBasic.PowerPacks.Vs, Version=10.0.0.0, Culture=neutral, PublicKeyToken=YADDAYADDA, processorArchitecture=msil' in the Global Assembly Cache
Assembly found at 'C:\WINDOWS\assembly\GAC_MSIL\Microsoft.VisualBasic.PowerPacks.Vs\10.0.0.0__b03f5f7f11d50a3a\Microsoft.VisualBasic.PowerPacks.Vs.dll'
Setting value '11.0.50727.1 {version}' for property 'VBPowerPacksInstalled'
The following properties have been set for package 'Microsoft Visual Basic PowerPacks 10.0':
Property: [VBPowerPacksInstalled] = 11.0.50727.1 {version}
Running checks for command 'VBPowerPacks\VisualBasicPowerPacksSetup.exe'
Result of running operator 'ValueExists' on property 'VBPowerPacksInstalled': true
Result of checks for command 'VBPowerPacks\VisualBasicPowerPacksSetup.exe' is 'Bypass'
'Microsoft Visual Basic PowerPacks 10.0' RunCheck result: No Install Needed
Running checks for package '.NET Framework 3.5 SP1', phase BuildList
Reading value 'SP' of registry key 'HKLM\Software\Microsoft\NET Framework Setup\NDP\v3.5'
Read integer value 1
Setting value '1 {int}' for property 'DotNet35SP'
The following properties have been set for package '.NET Framework 3.5 SP1': Property: [DotNet35SP] = 1 {int}
Running checks for command 'DotNetFX35SP1\dotNetFx35setup.exe'
Result of running operator 'ValueGreaterThanEqualTo' on property 'DotNet35SP' and value '1': true
Result of checks for command 'DotNetFX35SP1\dotNetFx35setup.exe' is 'Bypass'
'.NET Framework 3.5 SP1' RunCheck result: No Install Needed
Launching Application.
URLDownloadToCacheFile failed with HRESULT '-2146697205'
Error: An error occurred trying to download 'http://www.mywebsite.com/ProductName/Downloads/oneclick/ProductName.application'.
I've looked at https://msdn.microsoft.com/en-us/library/ms229001.aspx , after which I set the MIME type of .application to x-ms-application. No difference.
When I put the url http://www.mywebsite.com/ProductName/Downloads/oneclick/ProductName.application into my browser, I get the text of the file, rather than a download.
Any thoughts??? Thanks!
OK, the first thing that got me closer to the solution was simply to reboot the PC I was dwonloading onto. This got me further into the install, but I then ran into another problem, the solution to which I found at ClickOnce application replace current installed fliles . Clearing out the folder C:\Users\Charles\AppData\Local\Apps\2.0got me to where I could install and run the app fully.
Window application in C #. My solution, I hope it serves someone. The domain server was damaged, I just changed the IP of the new DNS server. It was not necessary to join that new domain server IP.
The "An error occurred trying to download.." error occurs with one of our click-once apps and the solution is to turn off IE Enhanced Security from Server Manager (Server 2012R2+) on the target machine.
Error 1 error MSB4018: The "MIDL" task failed unexpectedly.
System.TypeInitializationException: The type initializer for
'Microsoft.Build.Utilities.FileTracker' threw an exception. --->
System.IO.FileNotFoundException: The system cannot find the file
specified. (Exception from HRESULT: 0x80070002) at
System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32
errorCode, IntPtr errorInfo) at
System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32
errorCode) at
Microsoft.Build.Shared.NativeMethodsShared.ThrowExceptionForErrorCode(Int32
errorCode) at
Microsoft.Build.Shared.NativeMethodsShared.GetShortFilePath(String
path) at Microsoft.Build.Utilities.FileTracker..cctor() --- End of
inner exception stack trace --- at
Microsoft.Build.CPPTasks.TrackedVCToolTask.ComputeOutOfDateSources()
at Microsoft.Build.CPPTasks.TrackedVCToolTask.SkipTaskExecution() at
Microsoft.Build.Utilities.ToolTask.Execute() at
Microsoft.Build.CPPTasks.TrackedVCToolTask.Execute() at
Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.Execute()
at
Microsoft.Build.BackEnd.TaskBuilder.d__20.MoveNext()
C:\Program Files
(x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Microsoft.CppCommon.targets 1179
Is this problem affecting all projects?
I had similar problem when porting code from older version of VS. Form my experience the most errors are generated because paths. I do not remember details but using output paths explicitly (done in older versions) creates problem since project conversion mechanism tries to use macros and as a result in empty, wrongly formatted paths.
My advice is to verify all settings pertaining to output. Make sure OutputPath, TargetDir and others are set properly. Try changing settings and use to inherit from parent.
Create empty project of the same type and compare properties of both.