如何在使用Visual Studio Installer部署时设置WinForms应用程序的大小?

huangapple go评论56阅读模式
英文:

How to setup a WinForms application size when deploying with Visual Studio Installer?

问题

I have a WinForms application, everything works fine when I run it.
如果我运行它,一切都正常。

If I publish with the built-in publish tool, it also works fine. The form is the size I want after installation.
如果我使用内置的发布工具发布,也可以正常工作。安装后表单的大小是我想要的。

However, I want to use the Visual Studio Setup Project to create an installer for it. It can also install successfully, but the problem is that the form is a lot smaller compared to when I install it with the built-in publish tool or when I run it in Visual Studio.
然而,我想使用Visual Studio Setup Project创建一个安装程序。它也可以成功安装,但问题是与使用内置发布工具安装或在Visual Studio中运行时相比,表单要小得多。

I tried to add the manifest file and config file to the output, but it didn't help. The form is still very small and not the size I specified.
我尝试将清单文件和配置文件添加到输出,但没有帮助。表单仍然非常小,不是我指定的大小。

Maybe this is a dumb question but any help would be appreciated, thanks!
也许这是一个愚蠢的问题,但任何帮助都将不胜感激,谢谢!

Update:

My project framework is .NET Framework 4.8.
我的项目框架是.NET Framework 4.8。

I think this is a DPI awareness issue, but I have both the app.manifest and app.config file set up properly. Now the question is how do I make sure the Visual Studio Setup Project deploy my application using the settings I specified in the app.manifest and app.config files? I checked the installed files, there is a config file which is shown below.
我认为这是一个DPI感知问题,但我已经正确设置了app.manifest和app.config文件。现在的问题是如何确保Visual Studio Setup Project使用我在app.manifest和app.config文件中指定的设置部署我的应用程序?我检查了安装的文件,下面显示了一个配置文件。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <startup> 
        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
    </startup>
	<System.Windows.Forms.ApplicationConfigurationSection>
		<add key="DpiAwareness" value="PerMonitorV2" />
	</System.Windows.Forms.ApplicationConfigurationSection>
</configuration>

Then maybe it's a problem with the manifest file because I don't see a manifest file in the output folder? In project properties, I've selected app.manifest as my manifest file, but how do I add that to the Deployment project?
然后也许这是一个与清单文件有关的问题,因为我在输出文件夹中看不到清单文件?在项目属性中,我已经选择了app.manifest作为我的清单文件,但是如何将它添加到部署项目中?

英文:

I have a WinForms application, everything works fine when I run it.
If I publish with the built-in publish tool, it also works fine. The form is the size I want after installation.
built-in publish

However, I want to use the Visual Studio Setup Project to create an installer for it. It can also install successfully, but the problem is that the form is a lot smaller compared to when I install it with the built-in publish tool or when I run it in Visual Studio.

I tried to add the manifest file and config file to the output, but it didn't help. The form is still very small and not the size I specified.

Maybe this is a dumb question but any help would be appreciated, thanks!

Update:

My project framework is .NET Framework 4.8.

I think this is a DPI awareness issue, but I have both the app.manifest and app.config file set up properly. Now the question is how do I make sure the Visual Studio Setup Project deploy my application using the settings I specified in the app.manifest and app.config files? I checked the installed files, there is a config file which is shown below.

&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;configuration&gt;
    &lt;startup&gt; 
        &lt;supportedRuntime version=&quot;v4.0&quot; sku=&quot;.NETFramework,Version=v4.8&quot;/&gt;
    &lt;/startup&gt;
	&lt;System.Windows.Forms.ApplicationConfigurationSection&gt;
		&lt;add key=&quot;DpiAwareness&quot; value=&quot;PerMonitorV2&quot; /&gt;
	&lt;/System.Windows.Forms.ApplicationConfigurationSection&gt;
&lt;/configuration&gt;

Then maybe it's a problem with the manifest file because I don't see a manifest file in the output folder? In project properties, I've selected app.manifest as my manifest file, but how do I add that to the Deployment project?

答案1

得分: 0

这似乎是一个ClickOnce的问题。一旦我在安全选项卡中取消选中“启用ClickOnce安全设置”并重新构建了一切,应用程序在部署时看起来与我想要的一模一样。

英文:

Turns out it might be ClickOnce issue. Once I unchecked "Enable ClickOnce security settings" in the Security tab and rebuilt everything, the application looks exactly like I wanted it when I deployed with the Setup Project.

huangapple
  • 本文由 发表于 2023年6月9日 09:03:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76436568.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定