-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PostAction for modifying the deployment.template.json file in IoT Edge solutions #5831
Comments
Thank you for suggesting. To everyone, if you feel that this feature (or modifying JSON files in post action) is useful for you, please let us know your use case in comments or simply react to the issue. This helps us prioritize the relevant issues. Thank you. |
@vlada-shubina |
Unfortunately, we don't have any specific guideline for post actions specifically, but I can share the high-level steps here:
Please feel free to reach out if you need more information. Thank you |
Thanks for the information @vlada-shubina Next to that, if I succeed in creating such a post-action, will this only become available with .NET 8 ? |
It is possible to download latest daily version of .NET from https://aka.ms/dotnet/8.0.1xx/daily/dotnet-sdk-win-x64.exe (list of all the packages available here: https://github.com/dotnet/installer). If you are using VS, you would probably need to use latest preview that supports .NET 8. Alternatively, you can use release/7.0.2xx (or release/7.0.3xx once available) - they are built using .NET 7, and thats even more preferable. Depending on the when the PR will be ready, it might go with .NET SDK 7.0.200 or 7.0.300. The code freeze for 7.0.200 is in two weeks. |
I've been working on this for a while now, and I think I made some good progress. Suppose I have a template that looks like this (only relevant parts included): {
"name": "SomeTemplate",
"identity": "SomeTemplate",
"shortName": "SomeTemplate",
"sourceName": "MyProject",
"primaryOutputs": [
{
"path": "MyProject.csproj"
}
],
"postActions": [
{
"description": "Modify JSON file",
"args": {
"jsonFileName": "deployment.template.json",
"parentPropertyPath": "modulesContent:$edgeAgent:properties.desired:modules",
"newJsonPropertyName": "MyProject",
"newJsonPropertyValue": "{\"image\":\"${MODULEDIR<../MyProject>}\"}"
}
}
]
} As can be seen, the 'arguments' of the post-action contain some strings containing Is there any way to achieve this ? edit: I've currently 'worked around' this by making use of the filechanges in the |
I have created a (draft) Pull Request for this (dotnet/sdk#29880) . |
@fgheysels, just to make sure that I understand the scenario that you are proposing. The post action will add properties to a json file, and that post action can / will be used multiple times depending on the number of properties that you want to add to that specific json file. As for the file name, during post-actions we do not have ready access to the final name of the project files. You can read a bit more here on how we currently handle file names during that process. But, I think using |
Hi @maridematte |
Unfortunately, he |
This was fixed in dotnet/sdk#29880, @fgheysels contributed to create post action which covers the scenario. The example is here: https://github.com/dotnet/sdk/tree/main/src/Assets/TestPackages/dotnet-new/test_templates/PostActions/AddJsonProperty/WithSourceNameChangeInJson The documentation for new post action is here: https://github.com/dotnet/templating/wiki/Post-Action-Registry#add-a-property-to-an-existing-json-file |
Is your feature request related to a problem? Please describe.
I'm creating a project template for a custom IoT Edge module. When adding an iotedge module to an IoT Edge solution, you need to update the deployment.template.json file that is part of the solution to include that new module into the deployment.
It would be nice if there's a custom 'PostAction' which can do these modifications for you, as I currently don't see any way to do this myself.
As I read that the VS.NET extensions is in maintenance mode, and the CLI way will be the preferred way to create IoT Edge solutions / projects, this should be beneficial for Microsoft too ?
Describe the solution you'd like.
It would be nice if there would exist a PostAction that adds a new entry to the
modules
section of thedeployment.template.json
file that exists in an IoT Edge project.It would be helpfull if the developer could also specify the filename (or filenames) of this json file, as it is very much possible that an IoT Edge solution has multiple different deployment templates.
That new entry should look like this:
Where
IoTEdgeModule1
is the name of the new module. This could be thesourceName
property of the template.If this is too specific for a post-action, you could instead provide a post-action that is more generic. A post-action that allows the developer to add a JSON-object / subproperty to a specific property in a specific JSON file could maybe also do the job.
Additional context
No response
The text was updated successfully, but these errors were encountered: