usync.once / stop Files
usync.once and usync.stop are special files that you can use on your deployments to control how uSync imports will run at startup.
If your site has the ImportAtStartup setting configured to import items when the site starts up then the usync.once and usync.stop files will be checked.
Use usync.once in all lowercase. Linux file names are case-sensitive, so e.g. uSync.once will be ignored there.
usync.once​
If your uSync folder (uSync/v17) contains a usync.once file, uSync will perform an import at startup and then change the usync.once file into a usync.stop file.
usync.stop​
If the uSync folder contains a usync.stop file then uSync will not perform an import even if the ImportAtStartup setting is true.
One Time Import​
The main purpose of the usync.once and usync.stop files is to allow you to perform a one time import when you deploy your site, but then an import will not run should your site restart without deployment.
- Write a
usync.oncefile to the site on deployment. - When the site starts up uSync will perform an import and rename
usync.oncetousync.stop. - If the site restarts or reloads without a deployment the
usync.stopfile will prevent any imports from happening.
Adding the Once File at Publish.​
Adding the following to the .csproj file will create the Once file when you do a dotnet publish:
<!-- copy a "_usync.once" file to "uSync/v17/usync.once" on publish -->
<ItemGroup>
<ResolvedFileToPublish Include="uSync/_usync.once">
<RelativePath>uSync/v17/usync.once</RelativePath>
<CopyToPublishDirectory>Always</CopyToPublishDirectory>
</ResolvedFileToPublish>
</ItemGroup>
The version folder changes with each major version of uSync, so update this path when you upgrade, or set the file locations as shown below.
Adjusting the File Location​
Starting from v13.2.6 you can set the name and (relative) location for both the Once and Stop files in the appsettings.json file.
"uSync": {
"Settings": {
"ImportAtStartup": "All",
"StopFile": "../usync.stop",
"OnceFile": "../usync.once"
}
}
This will put them in the /uSync folder (assuming your files were in /uSync/v17). This will mean that if you do a clean export, your Once and Stop files will remain intact.