If you want to do it with ClickOnce, please refer to the following documents:
ClickOnce - Quick steps to Deploy, Install and Update Windows Based Client Applications.
Deploying Windows applications using ClickOnce (Visual Studio 2008)
How-To: Use ClickOnce to deploy your Applications
If you want to use Windows Installer(MSI), please refer to the following document:
Creating an MSI Package for C# Windows Application Using a Visual Studio Setup Project
For MSI, you need to install a Setup project to your VS:
Microsoft Visual Studio 2017 Installer Projects
How to install .vsix:
Developer Command Prompt for VS 2017
VSIXInstaller <path to vsix file>
中文参考:三五月儿 的 使用ClickOnce部署Windows应用程序
注意:与 Publishing Folder Location 相同
ClickOnce先决条件(Prerequisties)路径:C:Program Files (x86)Microsoft SDKsClickOnce BootstrapperPackages
ClickOnce安装路径:C:UserskylewAppDataLocalApps2.0 (保留当前版本和上一个版本)
获取ClickOnce安装路径:
System.Reflection.Assembly assemblyInfo = System.Reflection.Assembly.GetExecutingAssembly(); string assemblyLocation = assemblyInfo.Location; // MessageBox.Show(assemblyLocation); Uri uriCodeBase = new Uri(assemblyInfo.CodeBase); string ClickOnceLocation = Path.GetDirectoryName(uriCodeBase.LocalPath.ToString());//Path for cliconce installed location MessageBox.Show(ClickOnceLocation);
ClickOnce自定义先决条件:
Add your own (custom) prerequisite to "ClickOnce" application
Visual Studio Install 打包安装项目2017
ClickOnce获取当前版本号:
ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString();
ClickOnce获取项目中资源文件:
pictureBox1.Image = Image.FromFile(AppDomain.CurrentDomain.BaseDirectory + @"/img/a.jpg");
ApplicationDeployment.CurrentDeployment.DataDirectory + @"Database1.mdf"
中文参考:
英文参考:
ClickOnce: Concurrent versions
Trusted Click Once WPF setting
VS设置注册表项:
private void Form1_Load(object sender, EventArgs e)
{
label1.Text = GetRegistData("New Value #1");
//label2.Text = GetRegistData("New Value #2");
//label3.Text = GetRegistData("New Value #3");
}
// 读取注册表中相关数据
private static string GetRegistData(string name)
{
string registData;
RegistryKey hkml = Registry.CurrentUser;
RegistryKey software = hkml.OpenSubKey("SOFTWARE", true);
registData = software.GetValue(name).ToString();
return registData;
}