microsoft / msstore-cli

Microsoft Store CLI
MIT License
80 stars 8 forks source link

Failed to find the AppId. #14

Open ender-null opened 1 year ago

ender-null commented 1 year ago

Got this error, not sure what's the issue


Unhandled exception: MSStore.API.MSStoreException: Failed to find the AppId.
   at MSStore.CLI.Helpers.IStorePackagedAPIExtensions.EnsureAppInitializedAsync(IStorePackagedAPI storePackagedAPI, DevCenterApplication application, FileInfo directoryInfo, IProjectPublisher projectPublisher, CancellationToken ct) in /_/MSStore.CLI/Helpers/IStorePackagedAPIExtensions.cs:line [24](https://github.com/endworks/lovelust/actions/runs/5206050845/jobs/9392187704#step:15:25)0
   at MSStore.CLI.ProjectConfigurators.FileProjectConfigurator.PublishAsync(String pathOrUrl, DevCenterApplication app, DirectoryInfo inputDirectory, IStorePackagedAPI storePackagedAPI, CancellationToken ct) in /_/MSStore.CLI/ProjectConfigurators/FileProjectConfigurator.cs:line 152
   at MSStore.CLI.Commands.PublishCommand.Handler.InvokeAsync(InvocationContext context) in /_/MSStore.CLI/Commands/PublishCommand.cs:line 105
   at System.CommandLine.NamingConventionBinder.CommandHandler.GetExitCodeAsync(Object returnValue, InvocationContext context)
   at System.CommandLine.NamingConventionBinder.ModelBindingCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()```
azchohfi commented 1 year ago

It seems like you have not executed the init command for your project. Just run, locally and only once: msstore init. This will list your apps and let you select which app from the store this app is related to. Select the right one, and commit the file changes in your pubspec.yaml and whatever else is changed. This will let the CLI know which app you are trying to publish when the CI runs the publish command.

ender-null commented 1 year ago

Sorry for the delay in my response. I only receive this error: 💥 Could not retrieve your registered applications. Please try again.

azchohfi commented 1 year ago

Do you get any more details if you run it in verbose mode? Just add "-v" to the failing command.

ender-null commented 1 year ago

Doesn't make any sense, everything looks good to me.

09:48:51 info: Microsoft.Hosting.Lifetime[0] Application started. Press Ctrl+C to shut down.
09:48:51 info: Microsoft.Hosting.Lifetime[0] Hosting environment: CLI
09:48:51 info: Microsoft.Hosting.Lifetime[0] Content root path: A:\Documents\Projects\lovelust
09:48:51 info: MSStore.CLI.Program[0] Command is init
09:48:51 info: MSStore.API.StoreAPI[0] Getting DevCenter authorization token
09:48:51 info: System.Net.Http.HttpClient.Default.LogicalHandler[100] => HTTP GET https://manage.devcenter.microsoft.com/v1.0/my/applications?skip=0&top=100 Start processing HTTP request GET https://manage.devcenter.microsoft.com/v1.0/my/applications?skip=0&top=100
09:48:51 info: System.Net.Http.HttpClient.Default.ClientHandler[100] => HTTP GET https://manage.devcenter.microsoft.com/v1.0/my/applications?skip=0&top=100 Sending HTTP request GET https://manage.devcenter.microsoft.com/v1.0/my/applications?skip=0&top=100

⣷ Retrieving all registered applications...
                                           09:48:52 info: System.Net.Http.HttpClient.Default.ClientHandler[101] => HTTP GET https://manage.devcenter.microsoft.com/v1.0/my/applications?skip=0&top=100 Received HTTP response headers after 1092.1803ms - 400
⣯ Retrieving all registered applications...efault.LogicalHandler[101] => HTTP GET https://manage.devcenter.microsoft.com/v1.0/my/applications?skip=0&top=100 End processing HTTP request after 1097.6315ms - 400
                                           09:48:52 fail: MSStore.CLI.Commands.InitCommand.Handler[0] Error while retrieving applications. MSStore.API.MSStoreException: Failed to get the applications - {"code":"Unauthorized","message":"A valid account could not be found with given authorization token. CorrelationId=f34b4528-d558-434e-86de-b6c721b25632"}  ---> MSStore.API.MSStoreException: {"code":"Unauthorized","message":"A valid account could not be found with given authorization token. CorrelationId=f34b4528-d558-434e-86de-b6c721b25632"}    at MSStore.API.SubmissionClient.InvokeAsync[T](HttpMethod httpMethod, String relativeUrl, Object requestContent, CancellationToken ct) in /_/MSStore.API/SubmissionClient.cs:line 255    at MSStore.API.Packaged.StorePackagedAPI.GetDevCenterApplicationsAsync(Int32 skip, Int32 top, Cancellation💥 Could not retrieve your registered applications. Please try again.at MSStore.API.Packaged.StorePackagedAPI.GetApplicationsAsync(CancellationToken ct) in /_/MSStore.API/Packaged/StorePackagedAPI.cs:line 120    --- End of inner exception stack trace ---    at MSStore.API.Package
09:48:53 info: Microsoft.Hosting.Lifetime[0] Application is shutting down...
azchohfi commented 1 year ago

It seems like your credentials are invalid. I would try regenerating them and updating your secrets.

Juliotati commented 6 months ago

@ender-null you might have missed this step where you have to "Add Microsoft Entra application"

Account settings -> User management -> Microsoft Entra application then Add Microsoft Entra application

From there, add the application you created (or the CLI) created from "App registrations" and give it Manager(Windows) role

If you have the setup locally, try running msstore apps list. It should Retrieve Managed Applications

Screenshot 2024-03-30 at 13 34 02

Page link

Juliotati commented 6 months ago

make sure to included the --appId flag

msstore publish --appId ${{ secrets.MY_APP_ID }} -v