Specify which files are published by ClickOnce
When publishing a ClickOnce application, all required files in the project are deployed along with the application. The default set of required files is determined by the project type (for example, a Windows Forms app). In some cases, you may not want or need to publish certain files, or you may want to install certain files based on conditions. Visual Studio provides the capabilities to include files, exclude files, mark files as data files or prerequisites, and create groups of files for conditional installation.
Files for a ClickOnce application are managed in the Application Files dialog box, accessible from the Publish page of the Project Designer.
Initially, there is a single file group named (Required). You can create additional file groups and assign files to them. You cannot change the Download Group for files that are required for the application to run. For example, the application's .exe or files marked as data files must belong to the (Required) group.
The default publish status value of a file is tagged with (Auto). For example, the application's .exe has a publish status of Include (Auto) by default.
Files with the Build Action property set to Content are designated as application files and will be marked as included by default. They can be included, excluded, or marked as data files. The exceptions are as follows:
Data files such as SQL Database (.mdf and .mdb) files and XML files will be marked as data files by default.
References to assemblies (.dll files) are designated as follows when you add the reference: If Copy Local is False, it is marked by default as a prerequisite assembly (Prerequisite (Auto)) that must be present in the GAC before the application is installed. If Copy Local is True, the assembly is marked by default as an application assembly (Include (Auto)) and will be copied into the application folder at installation. A COM reference will appear in the Application Files dialog box (as an .ocx file) only if its Isolated property is set to True. By default, it will be included.
To add files to the Application Files dialog box
Select a data file in Solution Explorer.
In the Properties window, change the Build Action property to the Content value.
To exclude files from ClickOnce publishing
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
Note
In ClickOnce for .NET Core 3.1 and .NET 5 or later, you set deployment properties using the Publish tool instead of the Publish wizard and the Publish page of the Project Designer. For more information, see Deploy a .NET Windows application using ClickOnce and ClickOnce for .NET.
Click the Application Files button to open the Application Files dialog box.
In the Application Files dialog box, select the file that you wish to exclude.
In the Publish Status field, select Exclude from the drop-down list.
To mark files as data files
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
Click the Application Files button to open the Application Files dialog box.
In the Application Files dialog box, select the file that you wish to mark as data.
In the Publish Status field, select Data File from the drop-down list.
To mark files as prerequisites
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
Click the Application Files button to open the Application Files dialog box.
In the Application Files dialog box, select the application assembly (.dll file) that you wish to mark as a prerequisite. Note that your application must have a reference to the application assembly in order for it to appear in the list.
In the Publish Status field, select Prerequisite from the drop-down list.
To add a new file group
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
Click the Application Files button to open the Application Files dialog box.
In the Application Files dialog box, select the Group field for a file that you wish to include in the new group.
Note
Files must have the Build Action property set to Content before the file names appear in the Application Files dialog box.
In the Download Group field, select <New...> from the drop-down list.
In the New Group dialog box, enter a name for the group, and then click OK.
To add a file to a group
With a project selected in Solution Explorer, on the Project menu, click Properties.
Click the Publish tab.
Click the Application Files button to open the Application Files dialog box.
In the Application Files dialog box, select the Group field for a file that you wish to include in the new group.
In the Download Group field, select a group from the drop-down list.
Note
You cannot change the Download Group for files that are required for the application to run.