Closed leonAtRain closed 1 year ago
Hi @leonAtRain,
To instruct the Software Factory Execution to once-off create a file from a template, you can set the OverwriteBehaviour
in the GetTemplateFileConfig
method. By default this is set to OverwriteBehaviour.Always
, which instructs Intent Architect to continuously manage the file, but there are two other options:
OverwriteBehaviour.OnceOff
- Will only generate the file once ever and only if the file doesn't already exist. If the file is deleted for any reason, it is not generated again.
OverwriteBehaviour.OverwriteDisabled
- If a file already exists at the output path for the template instance, then it is NOT overwritten. If the template's output path has changed since the previous software factory execution AND no file exists at the new output path AND a file exists at the previous output path, then it is renamed/moved. If there is no longer any template instance outputting to the file output path, then it is deleted.
For example, if we wanted a Web.config
file to be created once-off:
public override ITemplateFileConfig GetTemplateFileConfig()
{
return new TemplateFileConfig(
overwriteBehaviour: OverwriteBehaviour.OnceOff,
codeGenType: CodeGenType.UserControlledWeave,
fileName: "Web",
fileExtension: "config",
);
}
Let us know if that doesn't solve your problem.
Good moring,
This is what I was looking for, and seeing that the file has no name, I've also implemented it like this:
public override ITemplateFileConfig GetTemplateFileConfig()
{
return new TemplateFileConfig(
overwriteBehaviour: OverwriteBehaviour.OnceOff,
fileName: $"",
fileExtension: "version"
);
}
Ask a question
I have a file that I need to add initially - but thereafter I don't want Intent to modify the file - the version file in the root folder. The problem is that there is only the version number in the file - how do I let Intent know to ignore the file if it exists already?