Announcement

Collapse
No announcement yet.

[OPEN] [#695] Support for Portable Class Libary?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

    [OPEN] [#695] Support for Portable Class Libary?

    Hi guys,

    Is is possible to compile a portable class library using saltarelle compiler?

    #2
    If you have the source for the PCL, I think the limitation would be more a matter of what C# API's might not be implemented in Bridge or Saltarelle.

    Theoretically there shouldn't be an issue for basic C# functionality, although some API's are not implemented and would fail compilation. Threading, Http requests, maybe some exceptions. Those come to mind first, as they do not have an equivalent in JavaScript.

    It would certainly be interesting to experiment. If you try, let us know how it works and we will do our best to assist.

    Comment


      #3
      Hi Geoffrey,

      I did test it quickly. install-package chokes, see below.
      I've created a Profile7 PCL (.net 4.5, win 8, asp.net core 5.0, Xamarin.[Android|iOS|iOS (Classic)].
      I wonder why does Saltarelle-Compiler NuGet package change framework to 2.0 -perhaps this is the problem?


      PM> Install-Package Saltarelle.Compiler
      Attempting to gather dependencies information for package 'Saltarelle.Compiler.2.7.0' with respect to project 'ClassLibrary1', targeting '.NETPortable,Version=v4.5,Profile=Profile7'
      Attempting to resolve dependencies for package 'Saltarelle.Compiler.2.7.0' with DependencyBehavior 'Lowest'
      Resolving actions to install package 'Saltarelle.Compiler.2.7.0'
      Resolved actions to install package 'Saltarelle.Compiler.2.7.0'
      Package 'Saltarelle.Compiler.2.7.0' already exists in folder 'g:\temp\tempprojects\TestSaltarelle\packages'
      Added package 'Saltarelle.Compiler.2.7.0' to 'packages.config'
      Executing script file 'g:\temp\tempprojects\TestSaltarelle\packages\Salt arelle.Compiler.2.7.0\tools\install.ps1'
      This reference cannot be removed from the project because it is always referenced by the compiler.
      At G:\temp\tempprojects\TestSaltarelle\packages\Salta relle.Compiler.2.7.0\tools\install.ps1:20 char:63
      + ... ct.Object.References | ? { $_.Name -eq "System" } | % { $_.Remove() }
      + ~~~~~~~~~~~
      + CategoryInfo : OperationStopped: (:) [], COMException
      + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

      This reference cannot be removed from the project because it is always referenced by the compiler.
      At G:\temp\tempprojects\TestSaltarelle\packages\Salta relle.Compiler.2.7.0\tools\install.ps1:21 char:75
      + ... ferences | ? { $_.Name.StartsWith("Microsoft.") } | % { $_.Remove() }
      + ~~~~~~~~~~~
      + CategoryInfo : OperationStopped: (:) [], COMException
      + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

      This reference cannot be removed from the project because it is always referenced by the compiler.
      At G:\temp\tempprojects\TestSaltarelle\packages\Salta relle.Compiler.2.7.0\tools\install.ps1:21 char:75
      + ... ferences | ? { $_.Name.StartsWith("Microsoft.") } | % { $_.Remove() }
      + ~~~~~~~~~~~
      + CategoryInfo : OperationStopped: (:) [], COMException
      + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException

      Successfully installed 'Saltarelle.Compiler 2.7.0' to ClassLibrary1

      Comment


        #4
        And mscorlib can't be easily added as well, since "it is automatically referenced by build system" it says.

        Comment


          #5
          I wonder why does Saltarelle-Compiler NuGet package change framework to 2.0 -perhaps this is the problem?
          We see this in the install.ps1 of the Saltarelle NuGet package.
          #Set the target framework to v2.0, otherwise we will have two System.Linq if installing the Linq package.
          $msbuild.SetProperty("TargetFrameworkVersion", "v2.0")
          I think we should have a look into that for Bridge v2 (based on Saltarelle) if there is a possibility to avoid forcing a change of .NET version.

          Created an Issue:
          https://github.com/bridgedotnet/Bridge2/issues/42

          Bridge2 is a private repo yet, but it will become public at some point.

          Meanwhile, Bridge v1 doesn't change .NET version. You could give it a try as well.
          Install-Package Bridge

          And mscorlib can't be easily added as well, since "it is automatically referenced by build system" it says.
          I guess it might be related to this Visual Studio bug.
          https://connect.microsoft.com/Visual...-nuget-restore

          It is tracked in this Bridge v1 issue, but it is also actual for Saltarelle.
          https://github.com/bridgedotnet/Bridge/issues/419

          A workaround is to manually unload and reload the project after NuGet package installation.

          Comment


            #6
            Brdidge won't install, either.

            Added package 'Bridge.1.9.0' to 'packages.config'
            Executing script file 'g:\temp\tempprojects\TestSaltarelle\packages\Brid ge.1.9.0\tools\install.ps1'
            This reference cannot be removed from the project because it is always referenced by the compiler.
            At G:\temp\tempprojects\TestSaltarelle\packages\Bridg e.1.9.0\tools\install.ps1:10 char:3
            + $_.Remove()
            + ~~~~~~~~~~~
            + CategoryInfo : OperationStopped: (:) [], COMException
            + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException
            It will produce a lot of these errors. I guess this is a no go in current situation. Hopefully you guys can address it for Bridge 2 :)
            I guess it might be related to this Visual Studio bug.
            https://connect.microsoft.com/Visual...-nuget-restore
            More probably, it is because PCL adds references to those libraries automatically and you can't remove them.

            Comment


              #7
              Hello MihaMarkic,

              Thanks for pointing out these installation issues. We will be investigating in detail.

              Our of interests sake, could you try installing Bridge 1.8.0 from NuGet:

              HTML Code:
              Install-Package Bridge -Version 1.8.0
              The 1.8.0 did not trigger the install.ps1 file, so theoretically Bridge should install, although there still may be issues with the native References during compilation. Just give it a try and see what happens.

              Comment


                #8
                I believe the issue might be with Xamarin Studio. If I understood well, you are using Xamarin Studio on Windows, thus with msbuild. I don't know why it does not allow you to remove references to mscorlib but we have a couple issues with this on Linux as well.

                First, we found that it ignores the NoStdLib option in the .csproj files, forcing us to manually check the Do not reference mscorlib.dll in the specific project options (Project > ProjectName options > Build > General). Second, when set, it spreads the NoStdLib tag all around the place in the .csproj files.

                As on Linux or Mac install.ps1 was never run though, we never noticed Xamarin actually did not allow it to remove references to Microsoft.* and System.*. This could be a hint for a better way to remove the StdLib (mscorlib) requirement during package installation (instead of inheriting the NoStdLib tag from the installed and imported .targets file).

                Comment


                  #9
                  Originally posted by fabricio.murta View Post
                  I believe the issue might be with Xamarin Studio. If I understood well, you are using Xamarin Studio on Windows, thus with msbuild. I don't know why it does not allow you to remove references to mscorlib but we have a couple issues with this on Linux as well.

                  First, we found that it ignores the NoStdLib option in the .csproj files, forcing us to manually check the Do not reference mscorlib.dll in the specific project options (Project > ProjectName options > Build > General). Second, when set, it spreads the NoStdLib tag all around the place in the .csproj files.

                  As on Linux or Mac install.ps1 was never run though, we never noticed Xamarin actually did not allow it to remove references to Microsoft.* and System.*. This could be a hint for a better way to remove the StdLib (mscorlib) requirement during package installation (instead of inheriting the NoStdLib tag from the installed and imported .targets file).
                  Just a quick reply. No, I am using Visual Studio 2015. Will check Geoffrey suggestion first.

                  Comment


                    #10
                    Added package 'Bridge.1.8.0' to 'packages.config'
                    Executing script file 'g:\temp\tempprojects\ClassLibrary3\packages\Bridg e.1.8.0\tools\install.ps1'
                    Originally posted by geoffrey.mcgill View Post
                    Hello MihaMarkic,

                    Thanks for pointing out these installation issues. We will be investigating in detail.

                    Our of interests sake, could you try installing Bridge 1.8.0 from NuGet:

                    HTML Code:
                    Install-Package Bridge -Version 1.8.0
                    The 1.8.0 did not trigger the install.ps1 file, so theoretically Bridge should install, although there still may be issues with the native References during compilation. Just give it a try and see what happens.
                    Hm, 1.8.0 triggers install.ps1 as well:
                    Added package 'Bridge.1.8.0' to 'packages.config'
                    Executing script file 'g:\temp\tempprojects\ClassLibrary3\packages\Bridg e.1.8.0\tools\install.ps1'
                    .... all the errors mentioned above

                    Comment


                      #11
                      Hm, 1.8.0 triggers install.ps1 as well:
                      Very strange. I pretty sure 1.8.0 did not include the install.ps1 process. I'm going to get Daniil involved in the discussion as he'll be able to clarify.

                      Try 1.7.0 and see what happens.

                      I apologise for the hassles.

                      Comment


                        #12
                        Originally posted by geoffrey.mcgill View Post

                        Very strange. I pretty sure 1.8.0 did not include the install.ps1 process. I'm going to get Daniil involved in the discussion as he'll be able to clarify.

                        Try 1.7.0 and see what happens.
                        Yup, 1.7. installs without problems. On compile it
                        1>g:\temp\tempprojects\ClassLibrary4\packages\Bridge.1.7.0\build\Bridge.targets(12,5): error : Error: Could not find file 'g:\temp\tempprojects\ClassLibrary4\ClassLibrary4\bin\Debug\System.Runtime.dll'.    at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
                        1>g:\temp\tempprojects\ClassLibrary4\packages\Bridge.1.7.0\build\Bridge.targets(12,5): error :    at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
                        1>g:\temp\tempprojects\ClassLibrary4\packages\Bridge.1.7.0\build\Bridge.targets(12,5): error :    at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
                        1>g:\temp\tempprojects\ClassLibrary4\packages\Bridge.1.7.0\build\Bridge.targets(12,5): error :    at Mono.Cecil.ModuleDefinition.GetFileStream(String fileName, FileMode mode, FileAccess access, FileShare share)
                        1>g:\temp\tempprojects\ClassLibrary4\packages\Bridge.1.7.0\build\Bridge.targets(12,5): error :    at Mono.Cecil.ModuleDefinition.ReadModule(String fileName, ReaderParameters parameters)
                        1>g:\temp\tempprojects\ClassLibrary4\packages\Bridge.1.7.0\build\Bridge.targets(12,5): error :    at Bridge.Translator.Translator.LoadAssembly(String location, List`1 references)
                        1>g:\temp\tempprojects\ClassLibrary4\packages\Bridge.1.7.0\build\Bridge.targets(12,5): error :    at Bridge.Translator.Translator.LoadAssembly(String location, List`1 references)
                        1>g:\temp\tempprojects\ClassLibrary4\packages\Bridge.1.7.0\build\Bridge.targets(12,5): error :    at Bridge.Translator.Translator.InspectReferences()
                        1>g:\temp\tempprojects\ClassLibrary4\packages\Bridge.1.7.0\build\Bridge.targets(12,5): error :    at Bridge.Translator.Translator.Translate()
                        1>g:\temp\tempprojects\ClassLibrary4\packages\Bridge.1.7.0\build\Bridge.targets(12,5): error :    at Bridge.Build.GenerateScript.Execute()
                        Originally posted by geoffrey.mcgill View Post
                        I apologise for the hassles.
                        Hey, no problems. I appreciate your help.

                        Comment


                          #13
                          By the way, is there a command line compiler? I assume Bridge works on assembly, not on source code.

                          Comment


                            #14
                            Yes, there is, but to use it you have to build Bridge from sources.

                            For Bridge 1.7.0 -- and other versions without install.ps1 -- whenever you create the project and install bridge, you have to remove the System.* and Microsoft.* references in the project. That was the step failing on your install.ps1. I'm not sure why VS2015 is restraining from removing references. I'm pretty sure we've tried this, at least on the Communitiy version -- and the install.ps1 did remove them.

                            Comment


                              #15
                              Found the commit where install.ps1 was added back. (It is in the private repo, but I still posted the link for others in Bridge.NET team who would like to review).

                              The commit happened on August 14.
                              The Bridge 1.8.0 NuGet package is dated as August 17.

                              So, install.ps1 appeared again in 1.8.0.

                              Comment

                              Working...
                              X