Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Copy to $(OutDir) does not copy to benchmarkdotnet output folder #946

Open
wazowsk1 opened this issue Nov 5, 2018 · 6 comments
Assignees

Comments

@wazowsk1
Copy link

@wazowsk1 wazowsk1 commented Nov 5, 2018

I have the following Copy action defined in my .csproj

<Target Name="CopyCustomContent" AfterTargets="AfterBuild">
   <Copy SourceFiles="@(files)" DestinationFolder="$(OutDir)" />
</Target>

When I try to run BenchmarkDotNet it does not copy the files to the \bin\release<Guid>... folder but just the default output folder.

What is the correct configuration to make this work?

@ydsood

This comment has been minimized.

Copy link

@ydsood ydsood commented Jul 17, 2019

Is there any solution for this issue so far?

@morgan-kn

This comment has been minimized.

Copy link
Collaborator

@morgan-kn morgan-kn commented Jul 22, 2019

In this case we can't just add Copy to SettingsWeWantToCopy because the Copy command contains parameters (i.e. SourceFiles, DestinationFolder, etc) which may refer to some properties in csproj, and we'll be forced to process them all.

I suggest to copy the content of user's bin folder to benchmark's bin folder assuming that user puts in there only files that he or she needs.

@adamsitnik What do you think?

@WojciechNagorski

This comment has been minimized.

Copy link
Collaborator

@WojciechNagorski WojciechNagorski commented Sep 25, 2019

Instead of post-build events you should use None or Compile items in your csproj, like below:

<ItemGroup>
  <None Include="$(MSBuildThisFileDirectory)..\x64\$(Configuration)\NativeDll.dll">
    <Link>NativeDll.dll</Link>
    <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    <Visible>True</Visible>
  </None>
</ItemGroup>

You can also copy the entire directory, using this method:

  <ItemGroup>
    <None Include="C:\Resources\**\*.*">
      <Link>%(Directory)\%(Filename)%(Extension)</Link>
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
      <Visible>True</Visible>
    </None>
  </ItemGroup>
@WojciechNagorski

This comment has been minimized.

Copy link
Collaborator

@WojciechNagorski WojciechNagorski commented Sep 30, 2019

I just blogged about this topic: https://wojciechnagorski.com/2019/09/using-native-dll-and-resource-files-in-benchmarkdotnet-projects/

I think BenchmarkDotNet should display a warning when AfterBuild or BeforBuild contains <Copy SourceFiles ...> in the csproj file.

@adamsitnik What do you think?

@adamsitnik

This comment has been minimized.

Copy link
Member

@adamsitnik adamsitnik commented Sep 30, 2019

I wonder if we could come up with a more generic solution implemented on the BDN side that would be transparent to the end-user. For example: by extending the auto-generated .csproj file with some MSBuild magic that would copy every native library from the benchmark project output folder to the auto-generated project output folder.

@eerhardt would copying all the files help with dotnet/performance#894 ? Do you have any suggestions for a more generic solution?

@eerhardt

This comment has been minimized.

Copy link
Member

@eerhardt eerhardt commented Sep 30, 2019

I agree with @wojtpl2 that using CopyToOutputDirectory on a None/Content item is probably best in this situation. It just works because we have a Project-to-Project Reference to the end-user's .csproj, and all the output items will get copied to the auto-generated .csproj.

As for helping with dotnet/performance#894, the native assemblies in that scenario should be getting copied to the output folder by default, because they come through a NuGet package. With the 3.0 .NET SDK, all the assets from NuGet packages should be copied to the output directory by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
7 participants
You can’t perform that action at this time.