![](/img/trans.png)
[英]Nuget Library - Copy DLL of Library to current project's output directory
[英]How to make VS to copy nuget packages dll's to output directory
我第一次嘗試在我的 WPF 項目上使用材料設計我從 nuget 安裝 package 但是當我嘗試運行它時它提示:
System.Windows.Markup.XamlParseException:'無法加載文件或程序集'MaterialDesignThemes.Wpf,文化=中性,PublicKeyToken=df2a72020bd7962a'。 該系統找不到指定的文件。'
當我手動將程序集復制到 output 文件夾時,它可以正常工作。
我的.csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
<BaseOutputPath>$(SolutionDir)\bin\</BaseOutputPath>
<OutputPath>$(SolutionDir)\bin\</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
<UseCommonOutputDirectory>true</UseCommonOutputDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MaterialDesignThemes" Version="4.6.1" />
<PackageReference Include="ShowMeTheXAML.MSBuild" Version="2.0.0" />
</ItemGroup>
</Project>
我試圖添加
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
但它什么都不做。
這是我的.csproj
<Project Sdk="Microsoft.NET. Sdk">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<Nullable>enable</Nullable>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="MaterialDesignThemes" Version="4.6.1" />
</ItemGroup>
</Project>
自動復制沒問題。 您的問題沒有發生。 您是否嘗試過重新創建一個項目,是否出現同樣的問題?
如果仍然不起作用,您可能需要添加 msbuild 事件來復制文件。 使用復制。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.