Page:12

# TOPIC:

## XSharp builds on .Net Core 29 Jul 2020 16:29 #15353

 robert Topic Author Posts: 1793 I would like to share some progress that I made today. I have changed the X# build system to support building for .Net Core. Consider an app that has one PRG file and a XSPROJ file. The contents of the XSProj file looks like this: Exe netcoreapp5.0 true vo  As you can see we are compiling for .Net Core 5.0 and for the VO dialect. I have included the XSharp assemblies needed to open a DBF file. The only "strange" thing in here is the package references to the System.Text.Encoding.CodePages package, because by default .Net Core does not have support for Codepage 1252 which I am using. Unlike traditional project files there are no items included. By default .Net Core includes all source code items in the folder. The code looks like this:USING System.Text FUNCTION Start() AS VOID FIELD CUSTNUM, LASTNAME, FIRSTNAME Encoding.RegisterProvider(CodePagesEncodingProvider.Instance) ? "Hello from X#" ? "OS :",OS(TRUE) ? "Framework:", System.Environment.Version:ToString() ? "Xsharp : version", Version(), "dialect", RuntimeState.Dialect:ToString() ? "Datetime :", DateTime() ? "Program :", ExecName(TRUE) ? "Workdir :", WorkDir() ? "Curdir :", System.IO.Directory.GetCurrentDirectory() ? "Opening, Indexing and listing a DBF with .Net Core" ? USE Customer INDEX ON LASTNAME TO LASTNAME DO WHILE ! EOF() ? Str(CUSTNUM,2) , LASTNAME, FIRSTNAME SKIP ENDDO ? "Press any key" Console.ReadLine() RETURN As you can see I am calling a function in the Encoding class to link the package that has the codepage support. The rest is a normal mixture of Xbase code and .Net code. To compile and run the program I typedotnet runon the command line. The result is this:Hello from X# OS : Windows 10 Enterprise (x64) ( Version 10.0, Build 18363 ) Framework: 5.0.0 Xsharp : version XSharp 2.5.2.0 dialect VO Datetime : 29-07-2020 16:10:58 Program : C:\test\bin\Debug\netcoreapp5.0\test.dll Workdir : C:\test\bin\Debug\netcoreapp5.0\ Curdir : C:\test Opening, Indexing and listing a DBF with .Net Core 6 Baker James 2 Borne Maria 15 Chandler Walter 3 Cooper Elizabeth 12 Cusumano Karen 5 Dougherty Janet . . 14 Walsh Gloria 19 Zimmerman Carla Press any key As you can see the runtime, RDD system and Macro compiler all work on .Net Core 5.0 ! You can deploy this app with all support DLLs in one single Exe and 2 small DLLs by calling:dotnet publish --self-contained true -r win-x64 -p:PublishSingleFile=true -p:PublishTrimmed=true  This creates the following files, which make up the whole program:29-07-2020 16:13 28.955.153 test.exe 28-05-2020 08:26 500.608 hostfxr.dll 28-05-2020 08:26 506.248 hostpolicy.dllEven the XSharp DLLs are included in test,exe. The total size is 29 Mb. You can also prepare an image for Linux by replacing win-x64 with linux-x64 and then the output is:29-07-2020 16:16 44.552.454 test 28-05-2020 07:54 563.728 libhostfxr.so 28-05-2020 07:54 532.408 libhostpolicy.soA self contained .Net app for Linux in 44 Mb ! I hope you find this interesting. Robert And yes this will be included in the next build. Not with the VS project system, that will take a bit longer. XSharp Development Team The Netherlands Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 29 Jul 2020 16:53 #15354

 wriedmann Posts: 2300 Hi Robert, that is really great, thank you very much! @Chris: It would be a cool thing to have this supported also in XIDE as it is my favourite development environment. Wolfgang Wolfgang Riedmann Meran, South Tyrol, Italy www.riedmann.it - docs.xsharp.it Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 29 Jul 2020 20:00 #15359

 Chris Posts: 2039 Hi Wolfgang, I wouldn't be surprised if there are absolutely zero changes needed in XIDE to support compiling for .Net Core. But will check when I get the new compiler from Robert! XSharp Development Team chris(at)xsharp.eu Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 29 Jul 2020 20:38 #15365

 robert Topic Author Posts: 1793 Chris, I did not make changes to the compiler for this. You can use the 2.5b compiler (actually all the 2.x compilers) for this. The changes are in the build system because: - you do not need to include the reference assemblies (except for some special references). - MsBuild automatically includes all relevant reference assemblies from the folder in"c:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0-preview.5.20278.1\ref" . The exact folder name depends on the framework chosen of course. For the test that I did with "netcoreapp5.0" that resulted in a list of over 150 assemblies. From what I see MsBuild simply includes all DLLs from that folder. - Of course we also need to use these assemblies inside the intellisense for type and member lookup. Robert XSharp Development Team The Netherlands Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 29 Jul 2020 20:57 #15366

 Chris Posts: 2039 Robert: Thanks, that's what I expected! Wolfgang: Have you tried compiling against the .Net code reference assemblies with the existing XIDE and compiler? I would not be surprised if that works already out of the box... XSharp Development Team chris(at)xsharp.eu Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 29 Jul 2020 21:07 #15367

 Meinhard Posts: 48 That sounds great Robert! Regards Meinhard Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 29 Jul 2020 21:16 #15368

 wriedmann Posts: 2300 Hi Chris, if I remember correctly, XIDE does not uses MSBuild, but calls the compiler directly, and the .NET Core thing is implemented in MSBuild. Wolfgang Wolfgang Riedmann Meran, South Tyrol, Italy www.riedmann.it - docs.xsharp.it Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 29 Jul 2020 23:48 #15370

 Chris Posts: 2039 Hi Wolfgang, What do you mean it is implemented in MSBuild? Doesn't it still use the compiler to simply create executable files? I remember during the Compact Framework early days when during a conference there were people from MS telling us that the only way to build compact framework apps was by using VS (not the other freeware alternative clones), and at the same time in another room another speaker was demonstrating writing compact framework apps in VIDE (as it was called back then) XSharp Development Team chris(at)xsharp.eu Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 30 Jul 2020 01:22 #15374

 ic2 Posts: 729 Let me try to summarize what I have collected and see where other readers may show if I am wrong somewhere: - .Net 4.8 is the last .Net Framework version. It is a stable Windows desktop only development environment. - .Net Core 3.0 is the last .Net Core version. It is multi platform (software will work on Linux or Mac) and it operates faster. But it is not yet matured, relies more on command prompt command and is harder to learn and use. - You can't just "go from .Net Framework to .Net Core" . If I take a look at docs.microsoft.com/en-us/dotnet/core/porting/ it is not something I would look forward to. - Around November 2020 .Net 5 will be released which is the next version of both .Net Core 3 and .Net Framework 4.8. - It is now possible to create an installation package to run a (any?) X# program on .Net Core. What is unclear to me is: 1 Will current & future .Net Framework programs stop running on .Net5 unless you go through Microsoft's impossible conversion routine? Or will that conversion no longer be needed in .Net 5? Or does anyone .not converting to .Net Core have to rely on 4.8 from 2019 for the length of years? .Net Framework 4.8 won't maintained anymore but only "supported as a Windows component on the latest required update for the operating systems W7 SP1, W8.1 + W10 from 1607). Hence a bit like VO it still works but it is not maintained. 2 Could X# users run all programs on .NetCore? Of course when using X# libs only (we reverted to the Vulcan DBFCDX system for some of our programs). Or isn't it that simple? More info in www.c-sharpcorner.com/article/difference...mework-and-net-core/ Dick Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 30 Jul 2020 06:10 #15375

 wriedmann Posts: 2300 Hi Chris, if I understand correctly what Robert wrote, the entire build process for .NET Core is done by MSBuild. This is not only done by compiling the source code, but also downloading the needed assemblies from somewhere (Nuget?). I have to look how to do that manually, or better, with XIDE. Currently I have no idea about that. Of course, .NET Core is not a requirement for the next days, but rather for the next months and years. Specially the possibility to build an all-inclusive executable is very interesting - it would simplify the upgrade process for my current type of work (several builds and installations of an application during a workday). Wolfgang Wolfgang Riedmann Meran, South Tyrol, Italy www.riedmann.it - docs.xsharp.it Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 30 Jul 2020 07:39 #15377

 Chris Posts: 2039 Hi Wolfgang, VS uses MSBuild to build projects, and without MSBuild you cannot do anything in VS, you cannot build even a simple standard .Net hello world app. XIDE does not use MSBuild, but you can still compile .Net programs. I do not see any reason for not being able to already write and compile .Net Core apps in XIDE, if you simply add references to the .Net Core dlls, instead of the standard .Net ones. XSharp Development Team chris(at)xsharp.eu Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 30 Jul 2020 08:06 #15378

 wriedmann Posts: 2300 Hi Chris, I will try that and let you know. From what I have seen in Fabrices session a few years ago in Köln is is not that easy. Wolfgang Wolfgang Riedmann Meran, South Tyrol, Italy www.riedmann.it - docs.xsharp.it Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 30 Jul 2020 08:16 #15379

 robert Topic Author Posts: 1793 Dick, At this moment .Net Framework, .Net Core, Mono and Xamarin are 4 implementations of the same .Net standard that live "side by side". The codebase for these 4 implementations is different, but they use the same underlying technology. Some types and methods exist in one platform and not in another. .Net Framework 4.8 and .Net Core 3.0 will be the last versions of these side by side .Net implementations. For the future Microsoft is merging the 4 frameworks into one (new) implementation, which is called .Net 5. Of course there are still differences between platforms, a Web server running on Linux does not have a windows desktop UI, but the source code for running .Net on WIndows desktop and Linux will be the same. So Microsoft will stop developing .Net Framework and .Net Core side by side. With .Net 5 you can target Desktop, Cloud, Mobile etc, based on the same code. There is one codebase and no longer different teams working on the runtimes. .Net 5 will live side by side with .Net 4.8. There will be no new development on .Net 4.8 anymore (most likely there will be bug fixes if for example security issues are found). To answer your second question: converted VO app running in X# can run on Windows Desktops, since they require a desktop. I do not think that converted VO apps can/will run on Mobile or Linux. Apps that use Windows.Forms for their UI may also run on Linux if there is an implementation of Windows Forms for Linux. I am not sure about that. Apps with just a Console UI or services can run on any platform. Robert EDIT: I should have probably named this thread: XSharp builds on .Net 5. The reason that I have chosen .Net Core is that with the same tooling I can also build for .Net Core 3 by choosing a different framework name in the MsBuild project file. XSharp Development Team The Netherlands Please Log in or Create an account to join the conversation. Last edit: by robert.

## XSharp builds on .Net Core 30 Jul 2020 08:46 #15380

 Chris Posts: 2039 Hi Wolfgang,wriedmann wrote: Hi Chris, I will try that and let you know. From what I have seen in Fabrices session a few years ago in Köln is is not that easy. Wolfgang Maybe Fabrice was using VS? XSharp Development Team chris(at)xsharp.eu Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 30 Jul 2020 10:21 #15382

 wriedmann Posts: 2300 Hi Chris, maybe Fabrice was using VS, but I'm not sure. Wolfgang Wolfgang Riedmann Meran, South Tyrol, Italy www.riedmann.it - docs.xsharp.it Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 30 Jul 2020 11:20 #15385

 Chris Posts: 2039 I was just kidding Wolfgang, of course Fabrice was using VS. I think that same with the compact framework, the only complexity is making VS actually support different environments through MSBuild. I do not expect there will be any issues compiling .Net Core apps in XIDE out of the box, just haven't tried it myself yet, just waiting for .Net Core to become a bit more mature first. But if you do try it, please let me know of your results! XSharp Development Team chris(at)xsharp.eu Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 30 Jul 2020 11:44 #15387

 wriedmann Posts: 2300 Hi Chris, for sure I will let you know! (if I succeed ever - I have my doubts....) Wolfgang Wolfgang Riedmann Meran, South Tyrol, Italy www.riedmann.it - docs.xsharp.it Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 30 Jul 2020 11:47 #15388

 ic2 Posts: 729 Hello Robert, Thanks for the explanation. It's certainly an achievement that you could compile a (basic) X# program for .Net Core and run it on Linux. About the new .Net5 Core: it was about time that Microsoft stopped doing the same thing in 4 different incompatible ways. But I am afraid it will be too late. We have seen that with the UWP apps which have been far from successful and are now slowly being abandoned. I have once published a C# program in the Windows Store using the Desktop Bridge but the whole program procedure was full of bugs and it took me days to convert it and this time I had the support of an Italian Microsoft guy who was very helpful. Probably I was one of the first users of this Desktop Bridge App . In the end not worth the time and effort. I am almost sure that any conversion to .Net Core is the same painstaking procedure. Which mean that the vast majority of the programs remain Windows Desktop programs in a .Net Framework versions which is no longer maintained. That is: if Framework programs require conversion to .Net 5 which I have not seen confirmed or denied yet. Then, after 2 or 3 years, Microsoft decides to abandon the idea again of having 1 .Net version and will start working again on new .Net Framework update. Just see Microsoft's history for that, WPF would take over Winforms and didn't, UWP would take over Desktop and it didn't, programs like OneNote Desktop would not receive further updates because there was a UWP app and then OneNote Desktop was suddenly revived again. Who knows they reintroduce the Windows Phone, running .Net Framework 4.9 Desktop programs. (Although I am clearly not a fan of Microsoft, the whole Windows Phone system was much nicer than Android). Dick Please Log in or Create an account to join the conversation. Last edit: by robert.

## XSharp builds on .Net Core 30 Jul 2020 15:10 #15392

 robert Topic Author Posts: 1793 Dick, This does not just work for Console Apps. I also have a Windows Forms app running with .Net 5 now. W.r.t. the "4 different things": Mono and Xamarin were developed by outside companies. Microsoft has acquired Xamarin and if I am correctly informed has hired the people behind Mono. They then started to work on .Net Core with the long term goal to make .Net Core so complete that it could replace .Net Framework. I think you can call .Net Core 2 and 3 "beta versions" of the new .Net 5, but I think Microsoft will never admit that. Now the moment has arrived that the new .Net 5 can replace all 4 predecessors. And I doubt that the conversion to .Net 5 will be painful. If it is then most people will not do it. This morning I have tried to see if I could compile XSharp.Core and XSharp.RT with .Net 5, and that was relatively easy. For XSharp.Core I got 2 compiler errors: - we have code that reads the OS() version from the registry. I needed to add a package reference to Microsoft.Win32.Registry - we are using a method String.Copy() which generates a warning that this method is now obsolete (see github.com/dotnet/runtime/issues/27515 ) XSharp.RT has a similar problem and also has a reference to System.Windows.Forms, which means that I need to set the Sdk value in the project to Microsoft.NET.Sdk.WindowsDesktop in stead of Microsoft.NET.Sdk Of course that means that that part of XSharp.RT will only work on Windows, but the code that does this contains a check to see if the app is running on windows. In the coming weeks I'll compile all the XSharp runtime DLLs with .Net 5 to make sure we are not using code that will not work on the next .Net. Robert XSharp Development Team The Netherlands Please Log in or Create an account to join the conversation.

## XSharp builds on .Net Core 30 Jul 2020 16:55 #15395

 ic2 Posts: 729 Hello Robert,robert wrote: Dick, And I doubt that the conversion to .Net 5 will be painful. If it is then most people will not do it. I hope you are right, and you may be given your own experiences. I have one more question. Suppose I target .Net Core (or later .Net5 ) for a current .Net Framework 4x application. Does that potentially prevent it from working on some Pc's? Or said otherwise: my own Pc is on W10 1903 and I apply security patches only every few months. This has apparently installed .NetCore 3.1.301 and .NetFramework 4.8.03752. Would you expect installation with a recent .Net Framework but with an old .NetCore so .NetCore program's won't work? Or are Core & Framework installed together (so both are an older version or both are recent)? PS: to check .Net Framework enter this in a DOS prompt: Reg query "HKLM\SOFTWARE\Microsoft\Net Framework Setup\NDP" /s The entry Version REG_SZ 4.8.03752 shows that you have 4.8. (I just saw I can't type 4 dot 8 with a ) because it makes a emoticon from it).... and this for .Net Core: dotnet --list-sdks 3.1.301 [C:\Program Files\dotnet\sdk] shows that you have Core 3.1) Dick Please Log in or Create an account to join the conversation. Last edit: by ic2.
 Page:12