TcOpenGroup / TcOpen

Application framework for industrial automation built on top of TwinCAT3 and .NET.
https://docs.tcopengroup.org/
MIT License
281 stars 48 forks source link

[QUESTION] Including own Library (which depends on TcOpen) in Project with TcOpen, how to make it work with Compiler #717

Open RGrabichler opened 4 months ago

RGrabichler commented 4 months ago

I have a Standard Library, which depends on TcOpen internally. I have a normal Project, where include TcOpen (compiler with net5.0 Library Project and 5.0 Blazor)

As soon as i include my own Library, the "reading identities" will not continue anymore.

How to solve this, perhaps a minimalistic Example, how to solve this.

RGrabichler commented 4 months ago

Now this is working, but i do not know why. Next Problem is, Inxton Compiler does not recognice my Structures, Fbs etc., so i cannot use them in HMI. image image image I have them instantiated with fully qualified name image

i tried to add the Connector Project of the library to the Project, and add a Project Reference from the Project Connector to the Library Connector, but i cannot get it to work.

What can i do

PTKu commented 4 months ago

Hey @RGrabichler

you may need to add the following to the csproj file of your connector project

<Content Include="_meta\{YourLibraryName}.library" IncludeInPackage="true" Pack="true" PackagePath="lib" CopyToOutputDirectory="PreserveNewest" />
    <Content Include="_meta\YourLibraryName.json" IncludeInPackage="true" Pack="true" PackagePath="lib" CopyToOutputDirectory="PreserveNewest" />          
    <Content Include="_meta\version.info" IncludeInPackage="true" Pack="true" PackagePath="lib" CopyToOutputDirectory="PreserveNewest" />   

https://github.com/TcOpenGroup/TcOpen/blob/c7ef91f9099ffd1a784ecc200078dd1e96267f6e/src/TcoCore/src/TcoCoreConnector/TcoCoreConnector.csproj#L34

let me know if that helps

RGrabichler commented 4 months ago

is this for NuGet Packages? can u provide a more detailed example.

Workflow should be (in 4026 changes)

I work on a plc library, then include it in plc project. In Plc Project i additionally have a Connector and a Blazor App. The Inxton Compiler does not recognice the FBs and Types from the Library.

If i add the above to ny csproj file, do i also have to the the "library Connector" to the Plc Project, and add the Include Lines there? or just in the Plc Project Connector (where does it get the Info from)

PTKu commented 4 months ago

It will include the metadata in the output (bin) folder of your library (besides packing it into NuGet when packing). The important part is the {YourLibraryName}.json file, which is where the compiler gets the information about the types that exist in the library. You should also check that your connector project contains {YourLibraryName}.json in the _meta folder.

You will also need to add your library project (connector and plc project) to your solution. If you do not want to do that, then you should release NuGet package and consume that.

RGrabichler commented 4 months ago

Thanks @PTKu, with the Inclusion of the Library-Connector in my Project and your proposed changes to the .csproj it is working.

One Problem, we talked about this earlier, where the "reading identities" not working anymore. It occurs sometimes, i do not know why. I have a Library Categories, when i make changes there, it stops working. Then i do not have another possibility to make it run again, as to copy a working Project, rename everything and copy my Library Content into it. Something very spooky is happening there

PTKu commented 4 months ago

There seems to be a problem with the ADS library v5 (which is currently unlisted on nuget.org). We observed this problem with another user but were never able to replicate it ourselves. The other user could use the .NET Framework 4.8 version for his application tough.

The issue might be solved when inxton libraries are ported to newer.NET versions. Unfortunatelly, the update brings some breaking changes that need to be solved. There are no immediate plans to update at this point, but we may do the update this fall together with upgrading to 4046. If we decide to port to higher .NET versions, they will remain experimental (as the v5 is).

The only supported version remains .NET Framework 4.8.