DNX Build Failed - Unexpected exit code received from msbuild.exe: 1 - msbuild

I cannot see why the below build is failing.
The project builds successfully.
What could "##[error]Unexpected exit code received from msbuild.exe: 1" result from in the below output?
Executing the powershell script: C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\tasks\VSBuild\1.0.13\VSBuild.ps1
C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe "C:\a\8ac4a4f6\Root\src\MyProject.Api\MyProject.Api.xproj" /nologo /m /nr:false /fl /flp:"logfile=C:\a\8ac4a4f6\Root\src\MyProject.Api\MyProject.Api.xproj.log" /dl:CentralLogger,"C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agent\worker\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agent\worker\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /t:Build,FileSystemPublish /p:PublishConfiguration=release /p:PublishOutputPathNoTrailingSlash=C:\a\8ac4a4f6\Root\MyProject\artifacts\bin\release\Publish /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="14.0"
Build started 8/3/2015 9:27:34 AM.
1>Project "C:\a\8ac4a4f6\Root\src\MyProject.Api\MyProject.Api.xproj" on node 1 (Build;FileSystemPublish target(s)).
1>PrepareForBuild:
Creating directory "..\artifacts\bin\MyProject.Api\".
Creating directory "..\artifacts\obj\MyProject.Api\any cpu\release\".
PreComputeCompileTypeScript:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4\tsc.exe --noEmitOnError COMPUTE_PATHS_ONLY
CompileTypeScript:
Skipping target "CompileTypeScript" because it has no outputs.
CoreCompile:
C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\dnx.exe --appbase "C:\a\8ac4a4f6\Root\src\MyProject.Api" "C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\lib\Microsoft.Framework.PackageManager\Microsoft.Framework.PackageManager.dll" pack "C:\a\8ac4a4f6\Root\src\MyProject.Api" --configuration release --out "..\artifacts\bin\MyProject.Api"
Microsoft .NET Development Utility CLR-x86-1.0.0-beta6-12256
Building MyProject.Api for DNX,Version=v4.5.1
Using Project dependency MyProject.Api 1.0.0
Source: C:\a\8ac4a4f6\Root\src\MyProject.Api\project.json
Using Project dependency MyProject.Domain.Model 1.0.0
Source: C:\a\8ac4a4f6\Root\src\MyProject.Domain.Model\project.json
... (deleted for readability)
Using Assembly dependency framework/fx/mscorlib 4.0.0.0
Source: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\mscorlib.dll
Using Assembly dependency framework/fx/System 4.0.0.0
Source: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.dll
... (deleted for readability)
The following commands will not be exported for global install: web.
MyProject.Api -> C:\a\8ac4a4f6\Root\src\artifacts\bin\MyProject.Api\release\MyProject.Api.1.0.0.nupkg
MyProject.Api -> C:\a\8ac4a4f6\Root\src\artifacts\bin\MyProject.Api\release\MyProject.Api.1.0.0.symbols.nupkg
Build succeeded.
0 Warning(s)
0 Error(s)
Time elapsed 00:00:09.0953302
Total build time elapsed: 00:00:09.1660739
Total projects built: 1
GetTypeScriptCopyToOutputDirectoryItems:
Adding items with BuildAction=TypeScriptCompile to the same collections that will be populated (with items of other BuildActions) by the GetCopyToOutputDirectoryItems target
GatherAllFilesToPublish:
Environment variables:
Path=C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\extensions\microsoft\web tools\external;C:\ProgramData\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\;C:\Program Files\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.0\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Users\VssAdministrator\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files (x86)\Microsoft Emulator Manager\1.0\;C:\Program Files (x86)\GtkSharp\2.12\bin;C:\Program Files (x86)\Microsoft SDKs\TypeScript\1.4\;C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\110\Tools\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\110\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;C:\NPM\Modules;C:\Program Files\nodejs\;C:\NPM\Modules;C:\cordova;C:\java\ant\apache-ant-1.9.4\bin;;C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\extensions\microsoft\web tools\external\.git
C:\Users\buildguest\.dnx\runtimes\dnx-clr-win-x86.1.0.0-beta6\bin\dnu.cmd publish "C:\a\8ac4a4f6\Root\src\MyProject.Api" --out "C:\a\8ac4a4f6\Root\MyProject\artifacts\bin\release\Publish" --configuration release --runtime dnx-clr-win-x86.1.0.0-beta6 --quiet
Microsoft .NET Development Utility CLR-x86-1.0.0-beta6-12256
Copying to output path C:\a\8ac4a4f6\Root\MyProject\artifacts\bin\release\Publish
Time elapsed 00:00:07.6405449
1>Done Building Project "C:\a\8ac4a4f6\Root\src\MyProject.Api\MyProject.Api.xproj" (Build;FileSystemPublish target(s)) -- FAILED.
Build FAILED.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:19.07
##[error]Unexpected exit code received from msbuild.exe: 1
global.json:
{
"sources": [ "src", "test" ],
"sdk": {
"version": "1.0.0-beta6",
"runtime": "clr",
"architecture": "x86"
}
}
project.json:
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Server.IIS": "1.0.0-beta6",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta6",
"Microsoft.AspNet.Mvc": "6.0.0-beta6"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --config hosting.ini"
},
"frameworks": {
"dnx451": { }
},
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
],
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
]
}
EDIT:
Removing the following arguments from msbuild.exe leads to a successful build:
/t:Build,FileSystemPublish /p:PublishConfiguration=release /p:PublishOutputPathNoTrailingSlash=C:\a\8ac4a4f6\Root\MyProject\artifacts\bin\release\Publish
There is clearly something wrong with my publish arguments.

I found the issue.
The following was throwing the exception:
dnu.cmd publish "C:\a\8ac4a4f6\Root\src\MyProject.Api" --out "C:\a\8ac4a4f6\Root\MyProject\artifacts\bin\release\Publish" --configuration release --runtime dnx-clr-win-x86.1.0.0-beta6 --quiet
I ran it without the --quiet argument and out comes an ArgumentNullException:
Restoring packages for C:\a\8ac4a4f6\Root\src\RelatedProject\project.json
----------
System.ArgumentNullException: Value cannot be null.
Parameter name: key
at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
at Microsoft.Framework.Runtime.Project.GetTargetFramework(FrameworkName targetFramework)
at Microsoft.Framework.Runtime.ProjectReferenceDependencyProvider.GetDescription(LibraryRange libraryRange, FrameworkName targetFramework)
at Microsoft.Framework.PackageManager.LocalWalkProvider.FindLibrary(LibraryRange libraryRange, FrameworkName targetFramework, Boolean includeUnlisted)
at Microsoft.Framework.PackageManager.RestoreOperations.<FindProjectMatch>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RestoreOperations.<FindLibraryMatch>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RestoreOperations.<FindLibraryEntry>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RestoreOperations.<CreateGraphNode>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RestoreCommand.<CreateGraphNode>d__71.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
at Microsoft.Framework.PackageManager.RestoreCommand.<RestoreForProject>d__70.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RestoreCommand.<>c__DisplayClass69_0.<<Execute>b__1>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.Framework.PackageManager.RestoreCommand.<Execute>d__69.MoveNext()
----------
Restore failed
Value cannot be null.
Parameter name: key
I removed the project dependency and it now works. I have no idea what the exception entails. Posted a question regarding that here.

I also faced this issue. I am posting this answer if somebody has a similar issue then try this solution. My visual studio solution has projects targeting different versions of .NET Framework (one project .NET 4.5.1 and the others .NET 4.5.2). It also has a database project with Target Platform set as Sql Server 2016.
I had to make sure all the projects in my solution are targeting .NET 4.5.2 and the database project's Target Platform set as Sql Server 2012. It's because our build server has a different version of Visual studio installed. So check the target frame works for your projects as well as if you have database projects then make sure they're targeting correct version of Sql Server.

Related

Docker Desktop installation failed:Failed to start service

Failed to start service: The service did not respond to the start or control request in a timely fashion
at CommunityInstaller.Service.Service.<StartAsync>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CommunityInstaller.Service.Manager.<AddServiceAsync>d__7.MoveNext()
Could you please resolve this?
Started on: 2021-06-05 19:17:13.110
File: C:\Users\****\AppData\Local\Docker\install-log.txt
CommandLine: "C:\***\Docker Desktop Installer.exe"
[19:17:13.119][ManifestAndExistingInstallationLoader] No install path specified, looking for default installation registry key
[19:17:13.122][Program] No installation found
[19:17:13.328][InstallWorkflow] Cancel pending background download
[19:17:13.352][InstallWorkflow] Using package: res:DockerDesktop
[19:17:13.355][InstallWorkflow] Downloading
[19:17:15.436][InstallWorkflow] Extracting manifest
[19:17:16.725][InstallWorkflow] Manifest found: version=64133, displayVersion=3.3.3, channelUrl=https://desktop.docker.com/win/stable/amd64/appcast.xml
[19:17:16.726][InstallWorkflow] Checking prerequisites
[19:17:17.599][InstallWorkflow] Prompting for optional features
[19:17:20.159][InstallWorkflow] Unpacking artifacts
[19:19:43.911][InstallWorkflow] Deploying component CommunityInstaller.CreateGroupAction
[19:19:48.727][InstallWorkflow] Deploying component CommunityInstaller.AddToGroupAction
[19:19:48.737][InstallWorkflow] Deploying component CommunityInstaller.ServiceAction
[19:19:48.740][InstallWorkflow-ServiceAction] Removing service
[19:19:48.744][InstallWorkflow-ServiceAction] Creating service
[19:19:51.300][InstallWorkflow] Installation failed
Exception type: System.Exception, Exception message: Component CommunityInstaller.ServiceAction failed: Failed to start service: The service did not respond to the start or control request in a timely fashion, StackTrace:
at CommunityInstaller.InstallWorkflow.<DoHandleD4WPackageAsync>d__29.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CommunityInstaller.InstallWorkflow.<DoProcessAsync>d__23.MoveNext()
[19:19:51.302][InstallWorkflow] Rollbacking component CommunityInstaller.AddToGroupAction
[19:19:51.304][InstallWorkflow] Rollbacking component CommunityInstaller.CreateGroupAction
[19:19:51.305][InstallWorkflow] Rollbacking component CommunityInstaller.UnpackArtifactsStep
[19:19:51.312][FileSystem] Deleting C:\Program Files\Docker\Docker
[19:19:51.758][FileSystem] Deleted C:\Program Files\Docker\Docker successfully
[19:19:51.759][InstallWorkflow] Rollbacking component CommunityInstaller.ExtractManifestStep
[19:19:51.760][InstallWorkflow] Rollbacking component CommunityInstaller.DownloadStep
Just disable the power service using the below steps,
Open msconfig.exe in the windows menu bar
Go to the "services" tab
Start typing "power" and it will auto find the correct service.
Untick the checkbox
Restart your PC
Make sure you do not have any Docker installation files in your
drive
Start the installation process again and hopefully that'll work for
you.

Azure DevOps + LibMan + UNPKG Intermittent Error LIB010: Failed to download resource from unpkg.com

I've setup Continuous Integration on Azure DevOps but I keep getting an intermittent issue whereby libman fails to download a resource here's a few examples:
##[error]libman.json(0,0): Error LIB010: Failed to download resource from "http://unpkg.com/devextreme#18.2.6/dist/css/icons/dxiconsmaterial.woff2"
##[error]libman.json(0,0): Error LIB010: Failed to download resource from "http://unpkg.com/globalize#1.4.2/dist/globalize-runtime/date.js"
##[error]libman.json(0,0): Error LIB010: Failed to download resource from "http://unpkg.com/cropperjs#2.0.0-alpha/src/js/preview.js"
It's always a different package that's causing the error so I'm assuming it's a timeout issue (either too slow or I'm abusing it - not sure).
Here's the actual exception message:
exception was thrown --- [d:\a\1\s\MyAppPortal\MyAppPortal.csproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.web.librarymanager.build\1.0.172\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [d:\a\1\s\MyAppPortal\MyAppPortal.csproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.web.librarymanager.build\1.0.172\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [d:\a\1\s\MyAppPortal\MyAppPortal.csproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.web.librarymanager.build\1.0.172\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : at Microsoft.Web.LibraryManager.CacheService.<RefreshCacheAsync>d__9.MoveNext() [d:\a\1\s\MyAppPortal\MyAppPortal.csproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.web.librarymanager.build\1.0.172\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : --- End of stack trace from previous location where exception was thrown --- [d:\a\1\s\MyAppPortal\MyAppPortal.csproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.web.librarymanager.build\1.0.172\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) [d:\a\1\s\MyAppPortal\MyAppPortal.csproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.web.librarymanager.build\1.0.172\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) [d:\a\1\s\MyAppPortal\MyAppPortal.csproj]
C:\Users\VssAdministrator\.nuget\packages\microsoft.web.librarymanager.build\1.0.172\build\Microsoft.Web.LibraryManager.Build.targets(35,9): error : at Microsoft.Web.LibraryManager.Providers.Unpkg.UnpkgProvider.<RefreshCacheAsync>d__22.MoveNext() [d:\a\1\s\MyAppPortal\MyAppPortal.csproj]
[error]C:\Users\VssAdministrator\.nuget\packages\microsoft.web.librarymanager.build\1.0.172\build\Microsoft.Web.LibraryManager.Build.targets(35,9): Error : Microsoft.Web.LibraryManager.Contracts.ResourceDownloadException: Failed to download resource from "http://unpkg.com/knockout#3.4.0/package.json"
at Microsoft.Web.LibraryManager.WebRequestHandler.<GetStreamAsync>d__5.MoveNext()
How can I remedy this issue? Is there a way of caching and reusing the downloaded packages on DevOps the same way VS does when running a build?
There's an updated version of the LibraryManager package which retries the downloads a few times. Install the latest and see if that helps with the problem.

VS for Mac doesn't build if Proxifier is running

Can not build in Visual Studio Mac (Used to be Xamarin)
Nothing builds or cleans. Not even a console app. I am using version 7.1.5 on macOS 10.12.6.
I uninstalled and reinstall and still the same issue.
Error: Build failed. See the build log for details.
This is the error in the build log:
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x00037] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:187
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:156
at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:128
at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in /private/tmp/source-mono-d15-3/bockbuild-d15-3/profiles/mono-mac-xamarin/build-root/mono-x64/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/TaskAwaiter.cs:535
at MonoDevelop.Projects.Project+<>c__DisplayClass142_1+<<RunMSBuildTarget>b__0>d.MoveNext () [0x00113] in /Users/builder/data/lanes/5123/7afedcae/source/monodevelop/main/src/core/MonoDevelop.Core/MonoDevelop.Projects/Project.cs:1200
--- End of stack trace from previous location where exception was thrown ---
Update1:
This only happens when I am using Proxifier Version 2.21
http://www.proxifier.com/mac/
Update2:
Filed as a bug here: https://bugzilla.xamarin.com/show_bug.cgi?id=60008
Also contacted proxifier.

Running ASP.NET 5 on Nano Server throws "Unable to load DLL 'kernel32'"

I have created a simple ASP.NET 5 project based on the ASP.NET 5 beta 8 Visual Studio template.
I have published the project using this command
dnu publish <path to project.json> --out <path to publish folder> --configuration Release --runtime dnx-coreclr-win-x64.1.0.0-beta8 --wwwroot-out "wwwroot" --no-source
After I run the web.cmd on nano server I received this error:
.\web.cmd : System.DllNotFoundException: Unable to load DLL 'kernel32': The specified module could not be found. (Exception from HRESULT:
0x8007007E)
+ CategoryInfo : NotSpecified: (System.DllNotFo...LT: 0x8007007E):String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
at Microsoft.AspNet.Server.Kestrel.Networking.PlatformApis.WindowsApis.LoadLibrary(String dllToLoad)
at Micros
oft.AspNet.Server.Kestrel.Networking.Libuv.Load(String dllToLoad)
at Microsoft.AspNet.Server.Kestrel.ServerFactory.Start(IFeatureCollection serverFeatures, Func`2 application)
at Microsoft.AspNet.Hosting.Internal.HostingEngine.Start()
at Microsoft.AspNet.Hosting.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.ApplicationHost.Program.ExecuteMain(DefaultHost host, String applicationName, String[] args)
at Microsoft.Dnx.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Dnx.Runtime.Common.EntryPointExecutor.Execute(Assembly assembly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Dnx.Host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env, String appBase, FrameworkName targetFramework)
at Microsoft.Dnx.Host.RuntimeBootstrapper.ExecuteAsync(String[] args, BootstrapperContext bootstrapperContext)
at Microsoft.Dnx.Host.RuntimeBootstrapper.Execute(String[] args, BootstrapperContext bootstrapperContext)
The same command doesn't throw this error when running on Windows 10. The application works fine on Windows 10.
Nano Server does not have kernel32.dll and advapi32.dll so code that is not linked against default libs won't work. You need to either link your code against onecore.lib or install reverse forwarders.
Reverse forwarders redirect calls to kernel32.dll/advapi32.dll APIs to the counterparts available on Nano Server.
On some OneCore systems (e.g. Win10 IoT Core on Raspberry Pi 2), reverse forwarders are installed by default. This is not the case in case of the Nano Server, since the goal is to make it as small as possible. Hence the need to install reverse forwarders manually if you need them.
To relate this to Asp.Net 5 - both Http Platform Handler and Kestrel (or to be more specific libuv) are linked against default libs. Therefore, to run Asp.Net 5 on Nano, you need forwarders, unless you use WebListener (which should work fine without forwarders).
Hypothesis
You mention that this application is working fine on Windows. How are you running it on Windows? There's a good chance you are using dnx451 and not dnxcore50 (CoreCLR) as your target platform.
This is a problem because you are publishing for CoreCLR. (--runtime dnx-coreclr-win-x64.1.0.0-beta8), and there's a good chance when you are running locally, it is using the full .NET framework.
Does It Work with CoreCLR on Windows 10?
Here's what I'd do: Try to run the web app in the Developer Command Prompt for Visual Studio 2015 using dnx.
Switch to the CoreCLR version of .NET using dnvm:
dnvm use 1.0.0-beta-8 -r coreclr
Restore packages
dnu restore
Run
dnx web
If this fails, we know what is the issue. If this succeeds, there's a chance that Nano doesn't provide the native Windows APIs your code is trying to execute. If that is the case, you have to identify the code that is causing this and use something else.
How to target only CoreCLR in Visual Studio
You can remove the dnx451 target from your project.json so that Visual Studio is forced to use the dnxcore50 (CoreCLR) version. Ideally we want to be running the exact same version / environment we are publishing to.

Run ASP.NET5 web application with Kestrel server on Windows

I have successfully run the 'HelloWeb' sample from the ASP.NET5 GitHub repo with the Kestrel server on Windows 8.1 by using:
dnx . kestrel
Now I want to run my own application with kestrel. I tried it from Visual Studio 2015RC and with several runtimes using dnx directly. The result is always:
System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the
requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeAssembly.get_DefinedTypes()
at Microsoft.AspNet.Hosting.Server.ServerLoader.LoadServerFactory(String serv
erFactoryIdentifier)
at Microsoft.AspNet.Hosting.Internal.HostingEngine.BuildApplication()
at Microsoft.AspNet.Hosting.Internal.HostingEngine.Start()
at Microsoft.AspNet.Hosting.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly ass
embly, String[] args, IServiceProvider serviceProvider)
at Microsoft.Framework.ApplicationHost.Program.ExecuteMain(DefaultHost host,
String applicationName, String[] args)
at Microsoft.Framework.ApplicationHost.Program.Main(String[] args)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Framework.Runtime.Common.EntryPointExecutor.Execute(Assembly ass
embly, String[] args, IServiceProvider serviceProvider)
at dnx.host.Bootstrapper.RunAsync(List`1 args, IRuntimeEnvironment env)
at dnx.host.RuntimeBootstrapper.ExecuteAsync(String[] args)
at dnx.host.RuntimeBootstrapper.Execute(String[] args)
Is there any way I can find what types cannot be loaded?
Update
Here is the project.json
{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Mvc": "6.0.0-beta6-14023",
"Microsoft.AspNet.Server.IIS": "1.0.0-beta6-11864",
"Microsoft.AspNet.Server.WebListener": "1.0.0-beta6-12245",
"Microsoft.AspNet.StaticFiles": "1.0.0-beta6-11996",
"EntityFramework.SqlServer": "7.0.0-beta6-13336",
"EntityFramework.Commands": "7.0.0-beta6-13336",
"Microsoft.Framework.ConfigurationModel.Json": "1.0.0-beta5-11337",
"Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta6-12521",
"Microsoft.AspNet.SignalR.Server": "3.0.0-beta6-12519",
"Microsoft.AspNet.Authentication.OAuthBearer": "1.0.0-beta4",
"Kestrel": "1.0.0-beta4"
},
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.WebListener --server.urls http://localhost:5000",
"kestrel": "Microsoft.AspNet.Hosting --server Kestrel --server.urls http://localhost:5004",
"ef": "EntityFramework.Commands"
},
"frameworks": {
"dnx451": { },
"dnxcore50": { }
},
"exclude": [
"wwwroot",
"node_modules",
"bower_components"
],
"publishExclude": [
"node_modules",
"bower_components",
"**.xproj",
"**.user",
"**.vspscc"
]
}
I tried to start it with Kestrel from within VS and set Kestrel to use the following runtime which resulted in the shown error messages in VS.
Runtime: 1.0.0-beta6-11921 .NET Framework x86
Exception thrown: 'System.Reflection.ReflectionTypeLoadException' in mscorlib.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
Exception thrown: 'System.Reflection.ReflectionTypeLoadException' in mscorlib.dll
Exception thrown: 'System.Reflection.ReflectionTypeLoadException' in Microsoft.Framework.ApplicationHost.dll
Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll
Exception thrown: 'System.Reflection.ReflectionTypeLoadException' in mscorlib.dll
Exception thrown: 'System.Reflection.ReflectionTypeLoadException' in dnx.host.dll
Final update
The problem was the kestrel package version. For whatever reason the Nuget manager only suggested me Kestrel beta 4 while all other packages got installed as beta 6. After manually setting Kestrel to beta 6 in project.json everything worked. I accept Gerald Davies answer as he gave me the right direction.
The error would seem to indicate a mismatch between the runtime being used, the runtime expected by the application, and possibly the dependencies available for the specific runtime.
First use dnvm list and verify which runtime is being used (active). Please post that in an update. If the wrong runtime is set to active you will need to change that using dnvm use. Also compare this to the values in global.json for your solution.
You may need to restore dependencies. This can happen if the build in VS is using a different runtime than what is set as active by dnvm. You can force a dependency restore by dnu restore.
A `dnu restore' is always needed but VS sometimes hides this by doing it automatically as dependencies change but only for the current runtime VS is executing against. Remember dependencies may vary by runtime.
This is complicated by the fact the VS uses global.json to determine which dnx to execute against (version, runtime, and architecture) but on the command line unless explicitly indicated dnx/dnu use the "active" runtime set by dnvm. Technically dnvm just sets the path to a particular runtime so when use execute dnx or dnu you are running a specific one (version, runtime, and architecture) depending on what the path is.
The key thing is that the dnx that VS executes against and the dnx that you execute against on the command line are not necessarily the same. Changing the "target" in VS (global.json) or in dnvm (dnvm use) doesn't automatically update the other.
So for example VS may automatically restore dependencies for the beta4 version of non-core clr x86 dnx but due to the path (set by dnvm) when you execute on the command line you are executing against beta6 version of the core clr x64. If those dependencies have not be restored then you will get an error.
To find the real cause of the exception, you can debug this error by using --debug switch of dnx. Try:
dnx --debug . kestrel
Then you can attach to dnx.exe with Visual Studio and see the exact exception and retrieve it's LoaderExceptions property. I had similar problems, both caused by runtime mismatch and source code errors.