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.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

billSP2 opened this issue · comments

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?

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