Could not find file '..\bin\Debug\TestProj.UnitTests.xunit.runner.json' - asp.net-mvc-5

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

Related

Unit Testing Works in VSCode on Windows but not Linux

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.

.netcore 3.1 Publish tasks error in Azure

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

assemblies not being included when deploying Azure webjobs

I have 3 files
MyWebJob.exe
MyClassLibraryProject.dll
3rdPartyLib.dll (vc++)
I zipped them and uploded it to web job, but I got error below.
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'MyClassLibraryProject.dll' or one of its dependencies. The specified module could not be found.
How to fix it , thanks!

unable to compile my c++ project after install VS 2012

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.

LiveTile plugin for Windows Phone 8 in Cordova 3.3

I have tried to add the LiveTile plugin (found here) to my clean Cordova 3.3 project. But I can't seem to get it to work. It works with the instruction from the link but that uses Cordova 2.0.0.
I get the following printout when I try to add a new Tile:
An exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll and wasn't handled before a managed/native boundary
A first chance exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll
An exception of type 'System.InvalidCastException' occurred in System.ServiceModel.Web.ni.dll and wasn't handled before a managed/native boundary
Unable to cast object of type 'System.Collections.Generic.List`1[System.Object]' to type 'System.Collections.Generic.Dictionary`2[System.String,System.Object]'.
Failed to deserialize Cordova.Extension.Commands.LiveTiles+LiveTilesOptions with JSON value :: ["System.Collections.Generic.Dictionary`2[System.String,System.Object]","LiveTiles963855178"]
A first chance exception of type 'System.NullReferenceException' occurred in CordovaWP8_2.9.14.DLL
An exception of type 'System.NullReferenceException' occurred in CordovaWP8_2.9.14.DLL but was not handled in user code
A first chance exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll
An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.ni.dll and wasn't handled before a managed/native boundary
ERROR: Exception in ProcessCommand :: Exception has been thrown by the target of an invocation.
ERROR: failed to InvokeMethodNamed :: createSecondaryTile on Object :: LiveTiles
The thread 0xbac has exited with code 259 (0x103).
Error occurred: Invalid action
Are plugins added differently with this new version of Cordova or is the LiveTile plugin simply not compatible anymore?
This might have been a dumb question, but since the documentation is so poor it is hard to call any question dumb.
I have however manage to solve this now, and in the off chance that someone else runs in to the same problem I'll try to explain what I did.
First I found this implementation of the LiveTiles plugin which seemed to be more recent then the one in the question. Instead of creating a new project through Visual Studio I used the CLI.
phonegap create hello com.example.hello HelloWorld
Then I used plugman to install the plugin according to the link above.
plugman install --project . --platform wp8 --plugin com.risingj.cordova.livetiles
Now I looked through my files to see what had happened.
config.xml - some addition
<?xml version='1.0' encoding='utf-8'?>
<widget>
<access origin="*" />
<feature name="LiveTiles">
<param name="wp-package" value="LiveTiles" />
</feature>
</widget>
a new file was generated: cordova_plugins.js in the www-folder with the following content:
cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
{
"file": "plugins/livetiles.js",
"id": "com.risingj.cordova.livetiles.livetiles",
"clobbers": [
"LiveTiles"
]
}
];
module.exports.metadata =
// TOP OF METADATA
{
"com.risingj.cordova.livetiles": "0.1.0"
}
// BOTTOM OF METADATA
});
I added these files to a Cordova Visual Studio-project and it worked! So I guess if a new plugin is added this is what is needed.
You need to do this :
cordova plugin add path/to/your/plugin
It will do all the stuff.

Resources