Hello thanks for reaching out!
Work on the UI thread:
- Requirement: Ensure calls touching DTE/SSIS objects run on the UI thread (use ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync).
- Get the SSIS project root item:
- Action: Locate the .dtproj EnvDTE.ProjectItem (the one representing the SSIS project) in project.ProjectItems. Retrieve the underlying SSIS object model:
- Action: From the SSIS project item, use ProjectItem.Object to get the SSIS project object.
- Goal: Access Microsoft.SqlServer.Dts.Runtime.Project and then its Project.Parameters collection Add or update the parameter:
- **Action:** If parameters.Contains(name) is false, call parameters.Add(name, TypeCode.String) and set parameter.Value = value. - **Optional:** Set **Sensitive**, **Required**, and **Description** to match your needs.- Mark the project as dirty:
- Action: Set the project’s dirty flag so VS knows it needs saving (e.g., via IVsHierarchy/IVsPersistHierarchyItem2 or by editing Project.params and marking it dirty).
- **
Simple fallback:** Call project.Save or DTE.Solution.SaveAll if available. Persist to disk (force save):- Action: Explicitly save both the dtproj and Project.params:
- Save the SSIS project (EnvDTE.Project.Save).
- If you edited the Parameters collection, ensure Project.params is saved; if needed, open it as a ProjectItem, edit, and call Document.Save. Trigger a refresh so the UI shows the change:
- Action: Explicitly save both the dtproj and Project.params:
- Mark the project as dirty:
- Action: Reload the SSIS project in VS:
- Use VS shell APIs to unload/reload the project (e.g., IVsSolution to reopen), or
- Close and reopen the Project.params document, or
- Collapse/expand the project node to force re-read Validate visibility in designer:
- **Action:** Open the SSIS Project Parameters window; confirm the parameter appears and matches the value. - **Check:** Build the project to ensure no parameter schema issues. **Handle edge cases (net effect you observed):** - **If parameter appears only after manual save/reload:** Ensure steps 5–7 are executed; the SSIS designer caches parameters, so a programmatic add must be followed by explicit save and refresh. - **Package into your extension command:** - **Action:** Wrap the logic into a command that: - Switches to UI thread - Adds/updates parameter - Saves dtproj and Project.params - Reloads project or refreshes items - Reports success/failure to the user.
- Collapse/expand the project node to force re-read Validate visibility in designer:
- Close and reopen the Project.params document, or