How do I build using the native corert preview? - c#

I have tried to get a .NET core 2.0 console application targeting win-x86 to build using the corert ilc compiler and microsoft linker.
So far I downloaded the latest version of the corert libraries and successfully built a preview using the release target as of commit c7781a90f00645f6bd06ef57e5d3fd879fe3e9a0.
I added build scripts rd.xml, ilc.rsp, and link.rsp, but I keep getting the message from ilc:
Error: Target architecture is not supported
Internal.CommandLine.CommandLineException: Target architecture is not supported
at ILCompiler.Program.Run(String[] args)
at ILCompiler.Program.Main(String[] args)
UPDATE: I was able to resolve the issue with the architecture, but now it is failing with a missing file reference:
C:\testapp>call "..\corert\bin\Windows_NT.x64.Release\tools\ilc.exe" ".\ilc.rsp"
Error: [TEMPORARY EXCEPTION MESSAGE] FileLoadErrorGeneric: Microsoft.Extensions.Options
Internal.TypeSystem.TypeSystemException+FileNotFoundException: [TEMPORARY EXCEPTION MESSAGE] FileLoadErrorGeneric: Microsoft.Extensions.Options
at Internal.TypeSystem.ThrowHelper.ThrowFileNotFoundException(ExceptionStringID id, String fileName)
at ILCompiler.CompilerTypeSystemContext.GetModuleForSimpleName(String simpleName, Boolean throwIfNotFound)
at Internal.TypeSystem.CustomAttributeTypeNameParser.GetTypeByCustomAttributeTypeName(ModuleDesc module, String name, Boolean throwIfNotFound, Func`4 resolver)
at Internal.TypeSystem.CustomAttributeTypeNameParser.GetTypeByCustomAttributeTypeName(ModuleDesc module, String name, Boolean throwIfNotFound, Func`4 resolver)
at ILCompiler.RdXmlRootProvider.ProcessTypeDirective(IRootingServiceProvider rootProvider, ModuleDesc containingModule, XElement typeElement)
at ILCompiler.RdXmlRootProvider.ProcessAssemblyDirective(IRootingServiceProvider rootProvider, XElement assemblyElement)
at ILCompiler.RdXmlRootProvider.AddCompilationRoots(IRootingServiceProvider rootProvider)
at ILCompiler.Compilation..ctor(DependencyAnalyzerBase`1 dependencyGraph, NodeFactory nodeFactory, IEnumerable`1 compilationRoots, DebugInformationProvider debugInformationProvider, Logger logger)
at ILCompiler.ILScannerBuilder.ToILScanner()
at ILCompiler.Program.Run(String[] args)
at ILCompiler.Program.Main(String[] args)
UPDATE 2: I was able to resolve the issues by finding references for all the missing files, but in the end I realized I needed to switch the architecture target to x64, however now it fails at the linker:
C:\testapp>call link #".\link.rsp"
libcpmt.lib(nothrow.obj) : fatal error LNK1112: module machine type 'x86' conflicts with target machine type 'x64'

The issue is caused by using the Developer Command Prompt instead of the x64 Native Tools Command Prompt. The former one targets x86 by default, but the latter one targets x64 and will link against the x64 libraries.

Related

unable to build xamarin forms 5.0.* locally from sources

Due to some custom reasons, we have some custom built-in features in the XF (like the XAML-based toolbar button and changing private-internal to the public classes, plus virtualizing some methods). As the result, we are dependent on the custom version of the XF NuGet package.
It worked (almost always) perfectly until the version XF5.0. I have a dedicated virtual machine with Windows and preinstalled VS for those purposes.
When I'm trying to build XF from sources using the next command
.\build.ps1 -Target NugetPack -ScriptArgs '--packageVersion="5.0.0.2013"'
I get the error:
Successfully created package 'L:\src_github\xf_patch_release-5.0.0-sr3.1\artifacts\Xamarin.Forms.Maps.WPF.5.0.0.2013.nupkg'.
NuGet Version: 5.9.1.11
Attempting to build package from 'Xamarin.Forms.temp.nuspec'.
Object reference is not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at NuGet.Packaging.PackageBuilder.<>c.<ValidateReferenceAssemblies>b__173_1(NuGet.Frameworks1204671.NuGetFramework groupFramework)
at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
at System.Collections.Generic.HashSet`1.UnionWith(IEnumerable`1 other)
at System.Collections.Generic.HashSet`1..ctor(IEnumerable`1 collection, IEqualityComparer`1 comparer)
at NuGet.Packaging.PackageBuilder.ValidateReferenceAssemblies(IEnumerable`1 files, IEnumerable`1 packageAssemblyReferences)
at NuGet.Packaging.PackageBuilder.Save(Stream stream)
at NuGet.Commands.PackCommandRunner.BuildPackage(PackageBuilder builder, String outputPath, Boolean symbolsPackage)
at NuGet.Commands.PackCommandRunner.BuildFromNuspec(String path)
at NuGet.CommandLine.PackCommand.ExecuteCommand()
at NuGet.CommandLine.Command.ExecuteCommandAsync()
at NuGet.CommandLine.Command.Execute()
at NuGet.CommandLine.Program.MainCore(String workingDirectory, String[] args)
An error occurred when executing task '_NuGetPack'.
Error: One or more errors occurred. (NuGet: Process returned an error (exit code 1).)
NuGet: Process returned an error (exit code 1).
I've tried to use different methods to get rid of this non-understandable issue, but nothing happened. I've tried to use the latest actual release-5.0.0-sr3.1 tag and the latest version of the branch 5.0.0
I've tried to change some settings in the build.cake file, to unload some projects from the solution (like UWP-related ones, which usually caused a lot of errors). I've tried to build the solution on my working computer (and environment) - I got the same result.
Then I switched to building the solution in the VS directly and started getting issues like:
Before calling the main task to build: .\build.ps1 -Target NugetPack... I always call the .\build.ps1 -Target provision to ensure that I haven't missed some required tools on each Windows OS.
Is there something that I have missed?
I've found out that I'm using a different version of the NuGet package manager, which I had to install globally on my OS. The right version can be found in the XF's Pipelines (https://dev.azure.com/xamarin/public/_build, see the Windows-related builds).
After I've changed the global version to 5.6.0, the build script started generating the *.nupkg file for the Xamarin.Forms project itself correctly.
...

Exception has occurred: CLR/System.Management.Automation.Runspaces.PSSnapInException when running simple PowerShell command

I'm trying to run an example C# program that's supposed to invoke a simple PowerShell command.
Unfortunately, I'm getting the following error message:
Exception has occurred: CLR/System.Management.Automation.Runspaces.PSSnapInException
An unhandled exception of type 'System.Management.Automation.Runspaces.PSSnapInException' occurred in System.Management.Automation.dll: 'System error.'
at System.Management.Automation.Runspaces.PSSnapInHelpers.LoadPSSnapInAssembly(PSSnapInInfo psSnapInInfo)
at System.Management.Automation.Runspaces.InitialSessionState.ImportPSSnapIn(PSSnapInInfo psSnapInInfo, PSSnapInException& warning)
at System.Management.Automation.Runspaces.InitialSessionState.CreateDefault()
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace(PSHost host)
at System.Management.Automation.Runspaces.RunspaceFactory.CreateRunspace()
at System.Management.Automation.PowerShell.Worker.CreateRunspaceIfNeededAndDoWork(Runspace rsToUse, Boolean isSync)
at System.Management.Automation.PowerShell.CoreInvokeHelper[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.CoreInvoke[TInput,TOutput](PSDataCollection`1 input, PSDataCollection`1 output, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke(IEnumerable input, PSInvocationSettings settings)
at System.Management.Automation.PowerShell.Invoke()
at ttps3.Program.Main(String[] args) in Z:\projects\easybell\ttps3\Program.cs:line 21
I'm running on C# SDK 5 and System.Management.Automation 7.1.3
System.Management.Automation is only usable in very limited scenarios. you can install the Microsoft.PowerShell.SDK nuget package instead.
Microsoft.PowerShell.SDK
Microsoft.PowerShell.SDK is a meta-package that pulls together all of the components of the PowerShell SDK into a single NuGet package. A self-contained .NET application can use Microsoft.PowerShell.SDK to run arbitrary PowerShell functionality without depending on any external PowerShell installations or libraries.
System.Management.Automation
The System.Management.Automation package is the heart of the PowerShell SDK and exists on NuGet chiefly as an asset for Microsoft.PowerShell.SDK to pull in. However, it can also be used directly as a package for smaller hosting scenarios and version-targeting modules.
Specifically, the System.Management.Automation package may be a preferable provider of PowerShell functionality when:
You’re only looking to use PowerShell language functionality (in the System.Management.Automation.Language namespace) like the PowerShell parser, AST and AST visitor APIs (for example for static analysis of PowerShell).
You only wish to execute specific commands from the Microsoft.PowerShell.Core module and can execute them in a session state created with the CreateDefault2 factory method.
PowerShellStandard.Library and other PowerShell reference assemblies
These reference assemblies do not include a runtime and require a global powershell installation that matches the reference assembly version.

Firestore functionality on a Windows iot core: error loading native library grpc_csharp_ext.x86.dll

Relatively new to the windows ecosystem. After following the windows documentation on setting up a background application on iot and google's quickstart for C#, I am receiving this error that I cannot seem to solve:
System.IO.IOException: 'Error loading native library "C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\BackgroundAppFirestoreOne-uwpVS.Debug_ARM.usernoname\grpc_csharp_ext.x86.dll". '
Stack Trace:
System.IO.IOException
HResult=0x80131620
Message=Error loading native library "C:\Data\Users\DefaultAccount\AppData\Local\DevelopmentFiles\BackgroundAppFirestoreOne-uwpVS.Debug_ARM.usernoname\grpc_csharp_ext.x86.dll".
Source=Grpc.Core
StackTrace:
at Grpc.Core.Internal.UnmanagedLibrary..ctor(String[] libraryPathAlternatives)
at Grpc.Core.Internal.NativeExtension.LoadUnmanagedLibrary()
at Grpc.Core.Internal.NativeExtension.LoadNativeMethods()
at Grpc.Core.Internal.NativeExtension..ctor()
at Grpc.Core.Internal.NativeExtension.Get()
at Grpc.Core.GrpcEnvironment.GrpcNativeInit()
at Grpc.Core.GrpcEnvironment..ctor()
at Grpc.Core.GrpcEnvironment.AddRef()
at Grpc.Core.Channel..ctor(String target, ChannelCredentials credentials, IEnumerable`1 options)
at Grpc.Core.Channel..ctor(String host, Int32 port, ChannelCredentials credentials, IEnumerable`1 options)
at Google.Api.Gax.Grpc.ChannelPool.GetChannel(ServiceEndpoint endpoint, IEnumerable`1 channelOptions, ChannelCredentials credentials)
at Google.Api.Gax.Grpc.ChannelPool.GetChannel(ServiceEndpoint endpoint, IEnumerable`1 channelOptions)
at Google.Cloud.Firestore.FirestoreDb.Create(String projectId, FirestoreClient client)
at BackgroundAppFirestoreOne.StartupTask.<Run>d__4.MoveNext() in C:\Users\usernoname\source\repos\BackgroundAppFirestoreOne\StartupTask.cs:line 95
The file is in the directory and does have the necessary permissions.
My environment:
Developing on Windows 10 with Visual Studios 2019 Enterprise
Deploying to a Dragonboard 410c with Windows 10 iot Core
Google.Cloud.Firestore NuGet referenced
I've tried:
Adding the gRPC.core as this suggested, as a NuGet package reference in VS2019, this did not solve the issue.
And I don't have any non-English characters as this suggests.
This error occurs when attempting to execute FirestoreDb db = FirestoreDb.Create(project);
(see line 44 of sample)
Does anyone know what this could be / what I could try to rectify?
I did not encount the exception with Google.Cloud.Firestore 1.1.0 on Windows IoT Core 17763. Could you please check the package version and OS version. BTW, it is not recommended to use the package in background app, since at the moment you can't register a headless app that uses filetypeAssociation, so that the app can not access the credential file(.json).

Unity gradle build failed

I can't build another APK in Unity. Always the same error.
CommandInvokationFailure: Gradle build failed.
C:/Program Files/Java/jdk1.8.0_171\bin\java.exe -classpath "C:\Program Files\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Tools\gradle\lib\gradle-launcher-4.0.1.jar" org.gradle.launcher.GradleMain "-Dorg.gradle.jvmargs=-Xmx2048m" "assembleRelease"
stderr[
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'gradleOut'.
> You have not accepted the license agreements of the following SDK components:
[Android SDK Build-Tools 27.0.1].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Alternatively, to learn how to transfer the license agreements from one workstation to another, go to http://d.android.com/r/studio-ui/export-licenses.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED in 1s
]
stdout[
NDK is missing a "platforms" directory.
If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to C:\Users\m-pro\AppData\Local\Android\Sdk\ndk-bundle.
If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning.
Checking the license for package Android SDK Build-Tools 27.0.1 in C:\Users\m-pro\AppData\Local\Android\Sdk\licenses
Warning: License for package Android SDK Build-Tools 27.0.1 not accepted.
]
exit code: 1
UnityEditor.Android.Command.WaitForProgramToRun (UnityEditor.Utils.Program p, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.Command.Run (System.Diagnostics.ProcessStartInfo psi, UnityEditor.Android.WaitingForProcessToExit waitingForProcessToExit, System.String errorMsg)
UnityEditor.Android.AndroidJavaTools.RunJava (System.String args, System.String workingdir, System.Action`1 progress, System.String error)
UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
Rethrow as GradleInvokationException: Gradle build failed
UnityEditor.Android.GradleWrapper.Run (System.String workingdir, System.String task, System.Action`1 progress)
UnityEditor.Android.PostProcessor.Tasks.BuildGradleProject.Execute (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEditor.Android.PostProcessor.PostProcessRunner.RunAllTasks (UnityEditor.Android.PostProcessor.PostProcessorContext context)
UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
My settings and things I've tried:
JDK version 1.8
SDK build tool version 25
I tried to copy "-dontwarn com.google.vr.ndk.base.DaydreamApi" into a proguard file (saw this type of a solution somewhere)
Swap from gradle build to internal build (as internal build a different error comes up)
Reinstall all and restart my computer :D
I had this same issue with my Unity builds after the build tools got an update, so you may just have to update them too.
as it says in the error message you need to accept the TOS using android studio
You have not accepted the license agreements of the following SDK components:
[Android SDK Build-Tools 27.0.1].
Before building your project, you need to accept the license agreements and complete the installation of the missing components using the Android Studio SDK Manager.
Install Android studio on your PC (if you havn't already)
run its SDK manager (configure > SDK manager > SDK tools)
If Android SDK build-tools says "Not installed", click the checkbox right next to it to install it.
if It says "Update available" click the checkbox with the "-" next to it so it shows a "✓"
hit apply, and accept the agreement.
That is what fixed it for me, hope this also works for you!
On OSX, I ran into this after upgrading from Unity 2020.3.24f1 to Unity 2020.3.38f1
What fixed it for me was getting the JDK and SDK paths from the Unity/Preferences/external tools, then in a terminal window:
export JAVA_HOME=<the JDK path Unity is using>
<SDK path Unity is using>/tools/bin/sdkmanager --licenses
for me this was:
export JAVA_HOME=/Applications/Unity/Hub/Editor/2020.3.38f1/PlaybackEngines/AndroidPlayer/OpenJDK
/Applications/Unity/Hub/Editor/2020.3.38f1//PlaybackEngines/AndroidPlayer/SDK/tools/bin/sdkmanager --licenses
This will then prompt to accept several licenses which appear under
/Applications/Unity/Hub/Editor/2020.3.38f1/PlaybackEngines/AndroidPlayer/SDK/licenses
Without the export JAVA_HOME to Unity's version, the sdkmanager --licenses would fail with a Java error.
After I figured this out on my own, I happened to notice the solution in Unity forums as well here: https://forum.unity.com/threads/gradle-build-faled.999773/

IntelliSense doesn't work in Visual Studio Code on Mac

I am using Visual Studio Code to develop an ASP.NET 5 application on Mac. The issue I am having is that I don't get any IntelliSense support (e.g. available class methods) beyond simple autocomplete for methods and variables names that I previously typed.
The app targets DNX Core 5.0:
"frameworks": {
"dnxcore50": { }
},
And I have CoreCLR 1.0.0-rc1-update1 installed via DNVM:
$dnvm list
Active Version Runtime Architecture OperatingSystem Alias
------ ------- ------- ------------ --------------- -----
1.0.0-rc1-update1 coreclr x64 darwin default
I tried the following to resolve the issue, but with no luck:
Made sure that a project is selected (fire icon in the bottom right corner)
Explicitly turned suggestions in settings.json
{
"editor.quickSuggestions": true`
}
Any suggestions will be much appreciated.
In short, the problem was that, while I had Mono installed on my machine, I didn't have DNX Mono. Installing it via DNVM locally (dnvm upgrade -r mono) resolved the issue and now I am having nice IntelliSense support in Visual Studio Code.
Now the long story.
Visual Studio Code uses OmniSharp to provide IntelliSense support. OmniSharp is a set of tools that provides C# code analysis services through a Nancy-based web API that runs on your machine (great posts on it here and here).
I didn't not get any IntelliSense because OmniSharp ran with errors which I could have easily caught if I paid more attention to Visual Studio Code Output window (Cmd+L L on Mac). OmniSharp Log (see below) shows that it tried to use dnx-mono.1.0.0-rc1-update1 runtime and then threw an exception because it was not there.
From what I understand, OmniSharp can't use DNX CoreCLR (because it doesn't support sockets?) and needs DNX Mono to run. There is some discussion on this topic in VS Code GitHub repo here.
Running dnvm upgrade -r mono and restarting Visual Studio Code fixed the issue. My DNVM set up now looks like this:
Please note that you don't have to use DNX Mono for development in order to get IntelliSense to work. You just need to have it installed.
OmniSharp Log
[INFO] Starting OmniSharp at APP_PATH...
[INFO] Started OmniSharp from '/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/jrieken.vscode-omnisharp/bin/omnisharp' with process id 34893...
[INFORMATION:OmniSharp.Startup] Omnisharp server running using stdio at location APP_PATH on host 34884.
[INFORMATION:OmniSharp.Dnx.DnxProjectSystem] Scanning APP_PATH for DNX projects
[INFORMATION:OmniSharp.Dnx.DnxPaths] Using runtime '/Users/nsamteladze/.dnx/runtimes/dnx-coreclr-darwin-x64.1.0.0-rc1-update1'.
[INFORMATION:OmniSharp.Dnx.DnxProjectSystem] Found project APP_PATH/project.json.
[INFORMATION:OmniSharp.Dnx.DesignTimeHostManager] Using '/Users/nsamteladze/.dnx/runtimes/dnx-mono.1.0.0-rc1-update1' for design time host.
[ERROR:OmniSharp.Startup] The project system 'DnxProjectSystem' threw an exception.
System.InvalidOperationException: File name has not been set
at System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) [0x00000] in :0
at System.Diagnostics.Process.Start () [0x00000] in :0
at (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
at OmniSharp.Dnx.DesignTimeHostManager.Start (System.String hostId, System.Action`1 onConnected) [0x00000] in :0
at OmniSharp.Dnx.DnxProjectSystem.Initalize (IConfiguration configuration) [0x00000] in :0
at OmniSharp.Startup.Configure (IApplicationBuilder app, IServiceProvider serviceProvider, ILibraryManager manager, IOmnisharpEnvironment env, ILoggerFactory loggerFactory, ISharedTextWriter writer, IOptions'1 optionsAccessor) [0x00000] in :0
[INFORMATION:OmniSharp.MSBuild.MSBuildProjectSystem] No solution files found in APP_PATH
[INFORMATION:OmniSharp.ScriptCs.ScriptCsProjectSystem] Detecting CSX files in APP_PATH.
[INFORMATION:OmniSharp.ScriptCs.ScriptCsProjectSystem] Could not find any CSX files
[INFORMATION:OmniSharp.Startup] Solution has finished loading

Categories

Resources