microsoft / powerplatform-build-tools

Power Platform Build Tools automate common build and deployment tasks related to Power Platform. This includes synchronization of solution metadata (a.k.a. solutions) between development environments and source control, generating build artifacts, deploying to downstream environments, provisioning/de-provisioning of environments, and the ability to perform static analysis checks against your solution using the PowerApps checker service.
MIT License
174 stars 37 forks source link

CS0246 The type or namespace name 'ScriptBase' could not be found #864

Closed billSP2 closed 2 months ago

billSP2 commented 2 months ago

Pardon the newbie question, but I'm tryng to create my first Power Automate connector with the goal of creating a connector for a home grown web service API.

My connector test is MySleepConnector.cs using System.Net.Http; using System.Threading; using System.Threading.Tasks; using Newtonsoft.Json.Linq;

public class Script : ScriptBase { public override async Task ExecuteAsync() { // Create a new response var response = new HttpResponseMessage();

    // Make an HTTP request to the specified webservice
    using (var httpClient = new HttpClient())
    {
        var sleepSeconds = 2.5; // The number of seconds to sleep (you can adjust this as needed)
        var url = $"https://httpstat.us/200?sleep={(int)(sleepSeconds * 1000)}";

        var result = await httpClient.GetAsync(url, CancellationToken.None);

        // Set the content of the response
        response.Content = CreateJsonContent(new JObject
        {
            ["status"] = result.StatusCode.ToString(),
            ["message"] = $"Slept for {sleepSeconds} seconds"
        }.ToString());
    }

    return response;
}

}

I'm receiving the following error when I perform a dotnet build. C:\Users\BillBaer\Support Partners\Assets for Marketing - Documents\Marketing Events\nab 2024\code\copilot\Sleep Connector\MySleepConnector.cs(6,23): error CS024 6: The type or namespace name 'ScriptBase' could not be found (are you missing a using directive or an assembly reference?) [C:\Users\BillBaer\Support Partners\A ssets for Marketing - Documents\Marketing Events\nab 2024\code\copilot\Sleep Connector\Sleep Connector.csproj]

I have tried following the directions on the Microsoft Learn website https://learn.microsoft.com/en-us/power-platform/developer/devtools-vs https://learn.microsoft.com/en-us/power-platform/developer/devtools-vs-create-project https://marketplace.visualstudio.com/items?itemName=microsoft-IsvExpTools.PowerPlatformToolsVS2022

but they appear to be all out of date with VS Code 1.89 which is what I'm using.

For example, they reference a menu option Tools>Connect to Dataverse, View>Power Platform Explorer which do not exist. I did locate the Power Platform Tools, but I've not figured out how to use the CLI to resolve the above error.

I must be missing something really obvious or not locating the latest docs for how to create a hello world Power Connector project in VS Code 1.89. Might anyone have advice on where to get started or how to solve the above error?

petrochuk commented 2 months ago

It looks like simple compile time error about missing ScriptBase class. Have you looked at Write code in a custom connector?

billSP2 commented 2 months ago

Andrew, Yes, I've reviewed that online help, but unfortunately it doesn't specify where Microsoft's ScriptBase abstract class is defined. The other online help is all based on Visual Studio 201x versions and the newer versions are not discussed. As a result, it is not possible to follow them when trying to locate this abstract class definition. Might you know how to add it to Visual Studio Code's current version or in the last 2 years? Bill

Bill Baer Global Director Business Development | Support Partners [cid:3940700f-2789-4d64-8da0-2c4c417c5006] E @.***

Direct: 408-455-6456 Support: @.**@.> Office: @.**@.>

London | New York | Scottsdale

[cid:4886b78d-b582-4227-97e0-38bb4bb0b7a7]https://support-partners.com/products-airarchive


From: Andrew Petrochuk @.> Sent: Sunday, May 5, 2024 5:20 PM To: microsoft/powerplatform-build-tools @.> Cc: Bill Baer @.>; Author @.> Subject: Re: [microsoft/powerplatform-build-tools] CS0246 The type or namespace name 'ScriptBase' could not be found (Issue #864)

Caution: This is an external email

It looks like simple compile time error about missing ScriptBase class. Have you looked at Write code in a custom connectorhttps://learn.microsoft.com/en-us/connectors/custom-connectors/write-code?

— Reply to this email directly, view it on GitHubhttps://github.com/microsoft/powerplatform-build-tools/issues/864#issuecomment-2095014508, or unsubscribehttps://github.com/notifications/unsubscribe-auth/BAWBSL3RBDTPA4CS46B2OJLZA3EDRAVCNFSM6AAAAABHGRU5GCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOJVGAYTINJQHA. You are receiving this because you authored the thread.Message ID: @.***>

The information contained in this transmission may be confidential. Any disclosure, copying, or further distribution of confidential information is not permitted unless such privilege is explicitly granted in writing by Support Partners. If received in error, please advise the sender and delete it immediately. We accept no liability for any loss or damage suffered by any person arising from use of this e-mail. The email and its content is subject to our Ts and Cs. E&OE. Support Partners (UK) Ltd. registered in England, Company Registration number 5173073. Registered office is Brigham House, High Street, Biggleswade, Bedfordshire SG18 0LD, United Kingdom. Support Partners (USA) Inc. registered in USA. 19 W 44th St, New York, NY 10036. 30-0836529