OfficeDev / generator-office

Yeoman generator for building Microsoft Office related projects.
https://www.npmjs.com/package/generator-office
MIT License
815 stars 207 forks source link

Manifest generated is invalid due to not creating a random GUID for the Id #824

Closed emmasab closed 2 months ago

emmasab commented 2 months ago

Expected behavior

Run yo office

Select the following

The manifest.xml produced contains a randomly generated GUID in the <id><\id> tag

Current behavior

The manifest.xml produced contains <Id>Add-In</Id> instead

Running npm run validate confirms the manifest is invalid

Error OfficeDev/generator-office#1:
XML Schema Validation Error: Error found during XML Schema validation.
  - Details: The 'http://schemas.microsoft.com/office/appforoffice/1.1:Id' element is invalid - The value 'Add-In' is invalid according to its datatype 'http://schemas.microsoft.com/office/appforoffice/1.1:UUID' - The Pattern constraint failed.
  - Line: 3
  - Column: 4

Error OfficeDev/generator-office#2:
XML Schema Violation: Your manifest does not adhere to the current set of XML schema definitions for Office Add-in manifests.

Error OfficeDev/generator-office#3:
Manifest product ID Not Valid: The manifest product ID could not be parsed. The ID must be a plain GUID.
  - Details: Add-In

The manifest is not valid.
Rick-Kirkham commented 2 months ago

@millerds I can reproduce. If the user gives a name with a space in it, the first word is put into the <DisplayName> element and the second word into the <Id> element.

This affects all project types except the manifest-only type.

I never use spaces in my project names, so I don't know how long it's been like this, but I think we'd have seen customer complaints if it had been very long.

millerds commented 2 months ago

I think this is a result of our moving the manifest update from generator-office to the convert script. You and repro this by running "npm run convert-to-single-host excel xml my add-in" in the template repo. The convert script line near the end that set's the cmdLine value needs to include quotes around the argument for the project name.

Rick-Kirkham commented 2 months ago

@millerds I think the damage is done before then. At the top where name and id are consecutive arguments:

const projectName = process.argv[4];  // = "my"
let appId = process.argv[5];          // = "add-in"

I think the generator has to put the display name in quotation marks. Then the line that sets the cmdline value doesn't need to change. If that seems right to you, should this move back to the generator repo?

millerds commented 2 months ago

@Rick-Kirkham Actually . . . I'm thinking now that it needs to be done in both places. They are both doing the same thing . . . that is taking a string argument and plugging it into another string that will be used as a cli command where any unquoted spaces get interpreted as argument separators. The symptoms reported here are based on the generator-office problem, but once that is fixed the project will be generated with a correct GUID, but the name will only be the first word instead of the whole thing.

I'll move this back because of the symptoms reported, but you'll need another issue for the templates for the fix there as well.

millerds commented 2 months ago

Fix is checked into the repo. Need change to taskpane repo in order to be effective. Will publish the generator-office change soon.

Rick-Kirkham commented 2 months ago

Change to conversion script is in 258.

millerds commented 2 months ago

Fix to generator-office has been published. Please update and it should work now.