我想将我的项目构建为独立的
.exe
或将其附带的所有文件放在子文件夹中。
构建信息:C#、.NET Framework 和 Visual Studio 2019 社区版。
当我构建项目时,它会输出这些文件:
Myapp.exe (of course)
Myapp.exe.config (I know this needs to be with the .exe)
Ookii.Dialogs.Wpf.dll
Ookii.Dialogs.Wpf.xml
我知道我可以用 fody Costura 构建它来集成
Ookii.Dialogs.Wpf.dll
并且可以工作,但它仍然有 .exe.config
和 Ookii.Dialogs.Wpf.xml
。
也许我不需要两者,配置文件中没有太多内容,但我需要
Ookii.Dialogs.Wpf.xml
吗?
如果是这样,是否可以将
Ookii.Dialogs.Wpf.xml
和 .exe.config
也添加到 .exe
中?
如果不可能在没有额外文件的情况下制作1个单独的
.exe
,我认为将所有文件放在一个子文件夹中会很方便,例如(/Config
),除了myapp.exe
之外。
那么它看起来像这样:
/Config
- Myapp.exe.config
- Ookii.Dialogs.Wpf.dll
- Ookii.Dialogs.Wpf.xml
Myapp.exe
希望有人能帮我解决这个问题。
.exe.config
(删除了令牌和应用程序名称):
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="myappnamehere" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=tokenhere" >
<section name="myapp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=tokenhere" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
<section name="myappnamehere.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=tokenhere" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
</sectionGroup>
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" />
</startup>
<userSettings>
</userSettings>
</configuration>
Ookii.Dialogs.Wpf.xml
代码中的一段 - 它非常大:
<?xml version="1.0"?>
<doc>
<assembly>
<name>Ookii.Dialogs.Wpf</name>
</assembly>
<members>
<member name="T:Ookii.Dialogs.Wpf.TaskDialogItemCollection`1">
<summary>
Represents a list of <see cref="T:Ookii.Dialogs.Wpf.TaskDialogItem"/> objects.
</summary>
<typeparam name="T">The type of the task dialog item.</typeparam>
<threadsafety instance="false" static="true"/>
</member>
<member name="M:Ookii.Dialogs.Wpf.TaskDialogItemCollection`1.ClearItems">
<summary>
Overrides the <see cref="M:System.Collections.ObjectModel.Collection`1.ClearItems"/> method.
</summary>
</member>
<member name="M:Ookii.Dialogs.Wpf.TaskDialogItemCollection`1.InsertItem(System.Int32,`0)">
<summary>
Overrides the <see cref="M:System.Collections.ObjectModel.Collection`1.InsertItem(System.Int32,`0)"/> method.
</summary>
<param name="index">The zero-based index at which <paramref name="item"/> should be inserted.</param>
<param name="item">The object to insert. May not be <see langword="null"/>.</param>
<exception cref="T:System.ArgumentNullException"><paramref name="item"/> is <see langword="null"/>.</exception>
<exception cref="T:System.ArgumentException">The <see cref="T:Ookii.Dialogs.Wpf.TaskDialogItem"/> specified in <paramref name="item"/> is already associated with a different task dialog.</exception>
<exception cref="T:System.InvalidOperationException">The <see cref="T:Ookii.Dialogs.Wpf.TaskDialogItem"/> specified in <paramref name="item"/> has a duplicate id or button type.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<para>
<paramref name="index"/> is less than zero.
</para>
<para>
-or-
</para>
<para>
<paramref name="index"/> is equal to or greater than <see cref="P:System.Collections.ObjectModel.Collection`1.Count"/>.
</para>
</exception>
</member>
<member name="M:Ookii.Dialogs.Wpf.TaskDialogItemCollection`1.RemoveItem(System.Int32)">
<summary>
Overrides the <see cref="M:System.Collections.ObjectModel.Collection`1.RemoveItem(System.Int32)"/> method.
</summary>
<param name="index">The zero-based index of the element to remove.</param>
<exception cref="T:System.ArgumentOutOfRangeException">
<para>
<paramref name="index"/> is less than zero.
</para>
<para>
-or-
</para>
<para>
<paramref name="index"/> is equal to or greater than <see cref="P:System.Collections.ObjectModel.Collection`1.Count"/>.
</para>
</exception>
</member>
<member name="M:Ookii.Dialogs.Wpf.TaskDialogItemCollection`1.SetItem(System.Int32,`0)">
<summary>
Overrides the <see cref="M:System.Collections.ObjectModel.Collection`1.SetItem(System.Int32,`0)"/> method.
</summary>
<param name="index">The zero-based index of the element to replace.</param>
<param name="item">The new value for the element at the specified index. May not be <see langword="null"/>.</param>
<exception cref="T:System.ArgumentNullException"><paramref name="item"/> is <see langword="null"/>.</exception>
<exception cref="T:System.ArgumentException">The <see cref="T:Ookii.Dialogs.Wpf.TaskDialogItem"/> specified in <paramref name="item"/> is already associated with a different task dialog.</exception>
<exception cref="T:System.InvalidOperationException">The <see cref="T:Ookii.Dialogs.Wpf.TaskDialogItem"/> specified in <paramref name="item"/> has a duplicate id or button type.</exception>
<exception cref="T:System.ArgumentOutOfRangeException">
<para>
<paramref name="index"/> is less than zero.
</para>
<para>
-or-
</para>
<para>
<paramref name="index"/> is equal to or greater than <see cref="P:System.Collections.ObjectModel.Collection`1.Count"/>.
</para>
</exception>
</member>
<member name="T:Ookii.Dialogs.Wpf.Properties.Resources">
<summary>
A strongly-typed resource class, for looking up localized strings, etc.
</summary>
</member>
<member name="P:Ookii.Dialogs.Wpf.Properties.Resources.ResourceManager">
<summary>
Returns the cached ResourceManager instance used by this class.
</summary>
</member>
<member name="P:Ookii.Dialogs.Wpf.Properties.Resources.Culture">
<summary>
Overrides the current thread's CurrentUICulture property for all
resource lookups using this strongly typed resource class.
</summary>
</member>
<member name="P:Ookii.Dialogs.Wpf.Properties.Resources.AnimationLoadErrorFormat">
<summary>
Looks up a localized string similar to Unable to load the progress dialog animation: {0}.
</summary>
</member>
<member name="P:Ookii.Dialogs.Wpf.Properties.Resources.CredentialEmptyTargetError">
<summary>
Looks up a localized string similar to The credential target may not be an empty string..
</summary>
</member>
<member name="P:Ookii.Dialogs.Wpf.Properties.Resources.CredentialError">
<summary>
Looks up a localized string similar to An error occurred acquiring credentials..
</summary>
</member>
<member name="P:Ookii.Dialogs.Wpf.Properties.Resources.CredentialPromptNotCalled">
<summary>
Looks up a localized string similar to PromptForCredentialsWithSave has not been called or the credentials were modified after the call..
</summary>
</member>
<member name="P:Ookii.Dialogs.Wpf.Properties.Resources.DuplicateButtonTypeError">
<summary>
Looks up a localized string similar to The task dialog already has a non-custom button with the same type..
</summary>
</member>
<member name="P:Ookii.Dialogs.Wpf.Properties.Resources.DuplicateItemIdError">
<summary>
Looks up a localized string similar to The task dialog already has an item with the same id..
</summary>
</member>
<member name="P:Ookii.Dialogs.Wpf.Properties.Resources.FileNotFoundFormat">
<summary>
Looks up a localized string similar to The file "{0}" could not be found..
</summary>
</member>
<member name="P:Ookii.Dialogs.Wpf.Properties.Resources.FolderBrowserDialogNoRootFolder">
<summary>
Looks up a localized string similar to Unable to retrieve the root folder..
</summary>
</member>
我已经做了什么:
Fody Costura 的 Ookii.Dialogs.Wpf.dll,它可以工作,但仍然得到其他文件。
要将 dll 放在子文件夹中,此代码也可以工作,但仅适用于 dll 文件...:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="Config" />
</assemblyBinding>
</runtime>