Signing invoice issue on linux and macOS

I have an issue when trying to sign an invoice using .Net 8 SDK on a mac os and i think the same issue may occur on linux also, I can generate a new CSR and proceed to compliance check step, but when signing an invoice, I receive the following exception:

System.IO.FileNotFoundException: Could not find file ‘/Users/mdameer/RiderProjects/ZatcaDemo/EasyConnect/EasyConnect.Web/bin/Debug/net8.0/…....\Data\Rules\schematrons\20210819_ZATCA_E-invoice_Validation_Rules.xsl’.

After investigatig the source code of the SDK, I found that the ConfigurationManager might be the main cause of this issue due to static windows style paths:

internal static string relativePathKSA = “…\…\…\Data\Rules\schematrons\20210819_ZATCA_E-invoice_Validation_Rules.xsl”;
internal static string KSA_Schematrons = ConfigurationManager.ReadResourceFromPath(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.relativePathKSA)));
internal static string relativePathEN = “…\…\…\Data\Rules\schematrons\CEN-EN16931-UBL.xsl”;
internal static string EN_Schematrons = ConfigurationManager.ReadResourceFromPath(Path.GetFullPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, ConfigurationManager.relativePathEN)));

This approach isn’t compatible with non-Windows platforms, any idea on how to solve this issue? or if anyone have experience with hosting the .Net 8 SDK on linux server?

1 Like

Dear @mdameer

Thanks for reaching out, Welcome to our community.

Can I Kindly ask you to answer these questions in order to ensure comprehensive support as usual:

1- What is the SDK version that you are using?
2- Did you check the signing documentation? If you don’t want to use our SDK tools?
3- Did you try to follow the steps mentioned in the Educational Library to ensure a successful onboarding and integrating with ZATCA.

For any further support, do not hesitate to reach out with the SP support via mail: sp_support@zatca.gov.sa.

Thanks,
Ibrahem Daoud.

@mdameer

I found the same problem when I run my application on ubuntu linux, and I agree with you that there is a problem in converting relative path to absolute path in Zatca.eInvoice.SDK library.

/mnt/c/Users/Incredible One/source/repos/ZatcaWithSDK/ZatcaWithSDK/bin/Debug/net8.0/..\..\..\Data\Rules\schematrons\20210819_ZATCA_E-invoice_Validation_Rules.xsl

I also use relative path in my application to point the location of template files and onboarding info my relativePath works fine on both windows and ubuntu linux.

public static string GetAbsolutePath(string relativePath)
{
    string baseDirectory = Directory.GetCurrentDirectory();
    string absolutePath = Path.Combine(baseDirectory, relativePath);
    string finalPath = Path.GetFullPath(absolutePath);
    Console.WriteLine(finalPath + " : " + System.IO.File.Exists(finalPath));
    return finalPath;
}