Buid Rapid SCADA 6 on Visual Studio Code

Forum Home Forums Development and Integration Buid Rapid SCADA 6 on Visual Studio Code

Viewing 15 posts - 1 through 15 (of 45 total)
  • Author
    Posts
  • #11179
    kumajaya
    Participant

    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#2004

    wget 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.0

    3. 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/vscode

    6. 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/Ubuntu

    sudo 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-staging

    3. Still from VS Code terminal:

    winecfg
    cd ScadaAdmin/bin/Release/net6.0-windows/win-x64/publish/
    WINEDEBUG=+loaddll wine ScadaAdmin.exe

    You will see some part of start page in grey background color, you can fix it:
    https://github.com/kumajaya/scada-v6/commit/b470b0c9f456b939714491cffa0ad92c7abd87e1

    Administrator run on Linux almost without problem except can’t connect to OPC UA server because crypto library incompatibility problem (Wine problem).

    #11186
    kumajaya
    Participant

    To run Administrator on a clean Wine environment:

    WINEPREFIX=~/.wine-scada6 winecfg
    WINEPREFIX=~/.wine-scada6 WINEDEBUG=+loaddll wine ScadaAdmin.exe

    ScadaAdmin on Wine, without any project:
    https://drive.google.com/file/d/17LDSfSQ0eMXccYcQt5p_Eva_okQ6axjJ/preview

    ScadaAdmin on Wine, without a project:
    https://drive.google.com/file/d/1RhNmUExJVh6gQ9rVDcr-R6pYuyk-Tiab/preview

    #11187
    kumajaya
    Participant

    ScadaAdmin on Wine, with a project and start page fix:
    https://drive.google.com/file/d/1Y0P4T5G_wUoaE-qWmK8CtArMz7oplSHt/preview

    #11192
    Mikhail
    Moderator

    That 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.

    #11228
    kumajaya
    Participant

    Administrator 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.
    #11230
    kumajaya
    Participant

    Scheme editor a bit problematic, the best solution for now run it using mono:

    mono ScadaSchemeEditor.exe

    #11236
    Mikhail
    Moderator

    Let’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.

    #11237
    kumajaya
    Participant

    Don’t worry, Administrator run so smooth on Wine.

    #11248
    kumajaya
    Participant

    My 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
    #11255
    Mikhail
    Moderator

    Could 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?

    #11257
    kumajaya
    Participant

    It’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!

    #11258
    Mikhail
    Moderator

    It 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?

    #11259
    kumajaya
    Participant

    I’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.

    #11260
    kumajaya
    Participant

    Yes, 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.
    #11262
    kumajaya
    Participant

    MonoDevelop 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.
Viewing 15 posts - 1 through 15 (of 45 total)
  • You must be logged in to reply to this topic.