Home > OS >  How to make VS to copy nuget packages dll's to output directory
How to make VS to copy nuget packages dll's to output directory

Time:01-02

I'm trying to use material design in the first time on my WPF project I install the package from nuget but when I'm trying torun it it's prompt:

System.Windows.Markup.XamlParseException: 'Could not load file or assembly 'MaterialDesignThemes.Wpf, Culture=neutral, PublicKeyToken=df2a72020bd7962a'. The system cannot find the file specified.'

When I'm copying the assemblies manually to the output folder it's works.

My .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>

I tried to add

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

but it does nothing.

CodePudding user response:

Here is my .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>

Auto copy is fine. Your problem did not occur. Have you tried recreating a project, does the same problem occur?

If that still doesn't work, you may need to add the msbuild event to copy the file. Use xcopy.

  • Related