Forum Home › Forums › Development and Integration › Buid Rapid SCADA 6 on Visual Studio Code
Tagged: ScadaAdmin, vscode, wine
- This topic has 44 replies, 3 voices, and was last updated 8 months ago by Mikhail.
-
AuthorPosts
-
October 7, 2022 at 6:00 am #11179kumajayaParticipant
Build Rapid SCADA 6 on Windows, Linux, or Mac
1. Install Visual Studio Code for your operating system:
https://code.visualstudio.com/2. Install .NET 6.0 SDK for your operating system:
Windows: https://learn.microsoft.com/en-us/dotnet/core/install/windows
Ubuntu 20.04: https://learn.microsoft.com/en-us/dotnet/core/install/linux-ubuntu#2004wget https://packages.microsoft.com/config/ubuntu/20.04/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt-get update
sudo apt-get install -y dotnet-sdk-6.03. Install git for your operating system:
Windows: https://gitforwindows.org/
Ununtu:sudo apt install git
4. Run Visual Studio Code and add “C# for Visual Studio Code” extension.
5. Clone a modified Rapid SCADA source from VS Code IDE:
https://github.com/kumajaya/scada-v6/tree/vscode6. Select “Run Build Task…” from Terminal menu, select build and then Release.
7. Enjoy the binaries built by yourself.
Make Administrator application run on Linux
1. Build ScadaAdmin from VS Code terminal, publishes the .NET runtime with application so the runtime doesn’t need to be installed on the target machine:
dotnet publish ScadaAdmin.sln -c Release -r win-x64 -p:PublishReadyToRun=true –self-contained
2. Still from VS Code terminal, install Wine:
https://wiki.winehq.org/Ubuntusudo dpkg –add-architecture i386
sudo mkdir -pm755 /etc/apt/keyrings
sudo wget -O /etc/apt/keyrings/winehq-archive.key https://dl.winehq.org/wine-builds/winehq.key
sudo wget -NP /etc/apt/sources.list.d/ https://dl.winehq.org/wine-builds/ubuntu/dists/focal/winehq-focal.sources
sudo apt install –install-recommends winehq-staging3. Still from VS Code terminal:
winecfg
cd ScadaAdmin/bin/Release/net6.0-windows/win-x64/publish/
WINEDEBUG=+loaddll wine ScadaAdmin.exeYou will see some part of start page in grey background color, you can fix it:
https://github.com/kumajaya/scada-v6/commit/b470b0c9f456b939714491cffa0ad92c7abd87e1Administrator run on Linux almost without problem except can’t connect to OPC UA server because crypto library incompatibility problem (Wine problem).
October 7, 2022 at 8:50 am #11186kumajayaParticipantTo run Administrator on a clean Wine environment:
WINEPREFIX=~/.wine-scada6 winecfg
WINEPREFIX=~/.wine-scada6 WINEDEBUG=+loaddll wine ScadaAdmin.exeScadaAdmin on Wine, without any project:
https://drive.google.com/file/d/17LDSfSQ0eMXccYcQt5p_Eva_okQ6axjJ/previewScadaAdmin on Wine, without a project:
https://drive.google.com/file/d/1RhNmUExJVh6gQ9rVDcr-R6pYuyk-Tiab/previewOctober 7, 2022 at 9:02 am #11187kumajayaParticipantScadaAdmin on Wine, with a project and start page fix:
https://drive.google.com/file/d/1Y0P4T5G_wUoaE-qWmK8CtArMz7oplSHt/previewOctober 7, 2022 at 11:24 am #11192MikhailModeratorThat is really interesting. Thanks a lot!
I will try to build Rapid SCADA using your description. I will write about my experience in this topic.
If you decided to make a guide with screenshots as a Word, Libre Office or Google document, it may be useful to save information.October 11, 2022 at 12:24 pm #11228kumajayaParticipantAdministrator run smoothly on Ubuntu Linux, feel like a native app. With all my patch to github, my publish command to make a single-file executable with dotnet runtime included:
From scada-v6 source root:
cd ScadaAdmin/ScadaAdmin dotnet publish ScadaAdmin.sln -c Release -r win-x64 --self-contained true -p:PublishReadyToRun=true -p:PublishSingleFile=true
and Administrator ready for us in:
ScadaAdmin/ScadaAdmin/ScadaAdmin/bin/Release/net6.0-windows/win-x64/publish
I believe a fix for crypto problem to make OPC UA client works will come from Wine soon or later.
- This reply was modified 1 year, 5 months ago by kumajaya.
October 11, 2022 at 12:31 pm #11230kumajayaParticipantScheme editor a bit problematic, the best solution for now run it using mono:
mono ScadaSchemeEditor.exe
October 11, 2022 at 1:12 pm #11236MikhailModeratorLet’s skip Scheme Editor for now. I hope we will make it web app in the future. But Administrator is too complex to make it web.
October 11, 2022 at 2:19 pm #11237kumajayaParticipantDon’t worry, Administrator run so smooth on Wine.
October 12, 2022 at 2:27 pm #11248kumajayaParticipantMy previous build still left some native library in place. For a big clean Administrator distribution:
cd ScadaAdmin/ScadaAdmin dotnet publish ScadaAdmin.sln -c Release -r win-x64 --self-contained true -p:PublishReadyToRun=true -p:PublishSingleFile=true -p:IncludeNativeLibrariesForSelfExtract=true
October 13, 2022 at 9:37 am #11255MikhailModeratorCould you provide additional instructions how to build the source with VS Code?
What actions should be performed to modify the projects as you did?I successfully installed VS Code, C# extension and .NET SDK on Ubuntu.
As a beginning, I just want to build the ScadaCommon solution.
In VS Code, I opened the folder ScadaCommon. A lot of files are marked red https://ibb.co/PtgT0x6
What should be the next steps to properly open the code and build it?October 13, 2022 at 11:31 am #11257kumajayaParticipantIt’s normal because no object reference anywhere yet. In VS Code terminal type:
dotnet build ScadaCommon.sln -c Release
You will got your first error because of cross compiling Windows app on Linux, modify ScadaCommon.Forms.csproj like:
<Copyright>Copyright © 2022</Copyright> <EnableWindowsTargeting>true</EnableWindowsTargeting>
Run again dotnet build, you will got your second error. Edit ScadaCommon.Svc.csproj like:
</Target> --> <ItemGroup> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets> </PackageReference> </ItemGroup> </Project>
Run dotnet build again, profit!
October 13, 2022 at 1:53 pm #11258MikhailModeratorIt helps. Thank you.
Using EnableWindowsTargeting is clear.The problem is that *.csproj files for classic .NET has complex structure. And it’s not good to edit them manually. I tried to add Microsoft.NETFramework.ReferenceAssemblies as NuGet package, but it doesn’t work. Do you think there is way to add the necessary changes to ScadaCommon.Svc.csproj with Visual Studio user interface?
October 13, 2022 at 4:13 pm #11259kumajayaParticipantI’m not familiar with VS. The compiler try to find .NetFramework v4.8:
error MSB3644: The reference assemblies for .NETFramework,Version=v4.8 were not found. To resolve this, install the Developer Pack (SDK/Targeting Pack) for this framework version or retarget your application. You can download .NET Framework Developer Packs at https://aka.ms/msbuild/developerpacks
and add per https://github.com/Microsoft/dotnet/tree/main/releases/reference-assemblies instructions:
<ItemGroup> <PackageReference Include="Microsoft.NETFramework.ReferenceAssemblies" Version="1.0.3" PrivateAssets="All" /> </ItemGroup>
fix it.
October 13, 2022 at 5:16 pm #11260kumajayaParticipantYes, we can use VS 2022 to add nuget package Microsoft.NETFramework.ReferenceAssemblies.net48 with a complex change to ScadaCommon.Svc.csproj and packages.config added with content:
<?xml version="1.0" encoding="utf-8"?> <packages> <package id="Microsoft.NETFramework.ReferenceAssemblies.net48" version="1.0.3" targetFramework="net48" developmentDependency="true" /> </packages>
As a patch to ScadaCommon.Svc.csproj:
@@ -12,6 +12,8 @@ <TargetFrameworkVersion>v4.8</TargetFrameworkVersion> <FileAlignment>512</FileAlignment> <TargetFrameworkProfile /> + <NuGetPackageImportStamp> + </NuGetPackageImportStamp> </PropertyGroup> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <DebugSymbols>true</DebugSymbols> @@ -53,7 +55,17 @@ <Name>ScadaCommon</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <Import Project="..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets" Condition="Exists('..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets')" /> + <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild"> + <PropertyGroup> + <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText> + </PropertyGroup> + <Error Condition="!Exists('..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets'))" /> + </Target> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. <Target Name="BeforeBuild">
- This reply was modified 1 year, 5 months ago by kumajaya.
October 13, 2022 at 5:35 pm #11262kumajayaParticipantMonoDevelop create a bit more simple changes with a same packages.config contents:
@@ -53,6 +53,9 @@ <Name>ScadaCommon</Name> </ProjectReference> </ItemGroup> + <ItemGroup> + <None Include="packages.config" /> + </ItemGroup> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <!-- To modify your build process, add your task inside one of the targets below and uncomment it. Other similar extension points exist, see Microsoft.Common.targets. @@ -61,4 +64,5 @@ <Target Name="AfterBuild"> </Target> --> + <Import Project="..\packages\Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets" Condition="Exists('..\packages \Microsoft.NETFramework.ReferenceAssemblies.net48.1.0.3\build\Microsoft.NETFramework.ReferenceAssemblies.net48.targets')" /> </Project> \ No newline at end of file
Both need a manual nuget CLI command to restore package:
mono /usr/local/bin/nuget.exe restore ScadaCommon.Svc/ScadaCommon.Svc.csproj -PackagesDirectory packages
- This reply was modified 1 year, 5 months ago by kumajaya.
-
AuthorPosts
- You must be logged in to reply to this topic.