簡體   English   中英

C# - 為什么 costura 和 fody 對我不起作用?

[英]C# - why costura and fody doesn't work to me?

(使用了翻譯器。)我正在使用 Costura 和 Fody 制作一個 exe 文件。 但是,如果 dll 文件丟失,則無法運行。 我的 Visual Studio 中有一個警告。 警告: FodyPackageReference Fody: The package reference for Costura.Fody is missing the 'compile' part in the IncludeAssets setting; it's recommended to completely remove IncludeAssets FodyPackageReference Fody: The package reference for Costura.Fody is missing the 'compile' part in the IncludeAssets setting; it's recommended to completely remove IncludeAssets

我也有這個警告。 但它對我來說很好。 因此,導致您的問題的不是警告。

在我看來,可能是因為 costura 版本不適合您的項目。 你可以試試舊版本。

至於我,我的項目使用的是 .net 框架 4.6,最新的 costura.fody 5.3 對我不起作用。 但是 5.2 工作正常。

以及如何刪除警告:(編輯 csproj 文件)

  1. 在解決方案資源管理器中右鍵單擊您的項目並 select 卸載項目右鍵單擊項目(在解決方案資源管理器中標記為不可用),然后單擊“編輯 yourproj.csproj”。 這將打開您的 CSPROJ 文件進行編輯。
  2. 在下面找到並評論“IncludeAssets”行如下
    <ItemGroup>
    <PackageReference Include="Costura.Fody">
    <Version>5.2.0</Version>
    <!--<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>-->
  1. 進行更改后保存,然后關閉文件。 再次右鍵單擊節點並在完成后選擇重新加載項目。

看起來像以前的答案,我以這種方式擺脫了警告:

  1. 雙擊項目節點
  2. 在 CSPROJ 文件中添加“compile;”:
    <IncludeAssets>runtime; compile; build;.....
  1. 重新加載項目

實際上,錯誤消息告訴您該怎么做:“...建議完全刪除 IncludeAssets”。

更具體地說,在您的項目文件(.csproj 或 .vbprog)中找到它作為示例的位置:

  <PackageReference Include="Fody">
  <Version>6.3.0</Version>
  <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
  <PrivateAssets>all</PrivateAssets>
  </PackageReference>

並將其更改為:

    <PackageReference Include="Fody">
    <Version>6.3.0</Version>
    <PrivateAssets>all</PrivateAssets>
    </PackageReference>

(即完全刪除 <IncludeAssets.....> 行)。

為costura 和fody 執行此操作(如適用)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM