0

I have a Visual Studio solution where I manage NuGet packages globally with a Packages.props file. I have a filesystem publishprofile. Now I added a reference to the NuGet package System.Diagnostics.DiagnosticSource. When I publish the project, the System.Diagnostics.DiagnosticSource.dll is not in the Bin folder of the publish directory. Other NuGet packages work as expected, so I assume that this has to do with the fact that we have a System. assembly here.

I tried things like:

 <ItemGroup>
    <None Update="bin\System.Diagnostics.DiagnosticSource.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

and

<Target Name="DiagFile">
    <ItemGroup>
      <_CustomFiles Include="bin\System.Diagnostics.DiagnosticSource.dll" />
      <FilesForPackagingFromProject Include="%(_CustomFiles.Identity)">
        <DestinationRelativePath>%(RecursiveDir)%(Filename)%(Extension) 
        </DestinationRelativePath>
      </FilesForPackagingFromProject>
    </ItemGroup>
  </Target>

but it doesn't work.

1
  • Does it work when you rebuild? Commented Jan 7, 2023 at 14:15

1 Answer 1

1

Might not be the best forum for this question; I would not have thought that you'd need to go to this length. I presume you mean you are using PackageReference dependency packaging rather than packages.config?

I just created a blank ASPNET (Framework 4.7.2) app to test with. I added the System.Diagnostics.DiagnosticSource package and ran a publish to File System and the DLL was in the published bin directory. This was using the packages.config model which is the default for this project type.

Converting to PackageReference mode, I can see the package has been referenced into the project in a pretty normal way...

<ItemGroup>
    <PackageReference Include="System.Diagnostics.DiagnosticSource">
      <Version>6.0.0</Version>
    </PackageReference>
</ItemGroup>

Publishing to File System still delivers the file to the bin directory. I haven't added any code to the project whatsoever at this point.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.