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

Subdirectories are ignored when including files without extension #5898

Closed
jp2masa opened this issue Sep 15, 2017 · 4 comments
Closed

Subdirectories are ignored when including files without extension #5898

jp2masa opened this issue Sep 15, 2017 · 4 comments

Comments

@jp2masa
Copy link

jp2masa commented Sep 15, 2017

(I'll try to fix this and I know where the problem is, but if this behaviour is expected and this isn't a bug, please point me in the right direction. The behaviour is expressed in this statement: https://github.com/NuGet/NuGet.Client/blob/dev/src/NuGet.Core/NuGet.Build.Tasks.Pack/PackTaskLogic.cs#L426)

If I add this to my project file:

<Content Include="tools\**">
    <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    <Pack>True</Pack>
    <PackagePath>tools\</PackagePath>
</Content>

And I have for example these files:

  • tools\folder1\file1.cs
  • tools\folder2\file2.cs
  • tools\folder2\file (no extension)

"file" will be copied to "tools\", while "file1.cs" will be copied to "tools\folder1\" and "file2.cs" will be copied to "tools\folder2\"

@zhili1208
Copy link
Contributor

@rohit21agrawal

@jp2masa
Copy link
Author

jp2masa commented Sep 15, 2017

I was trying to fix this now and this is what I can think of:
Code:

foreach (var targetPath in targetPaths)
{
    newTargetPaths.Add(PathUtility.GetStringComparerBasedOnOS().
        Compare(Path.GetExtension(fileName),
        Path.GetExtension(targetPath)) == 0
            ? targetPath
            : Path.Combine(targetPath, recursiveDir));
}

A condition can be added to check if the file extension isn't String.Empty, but that would remove the option of specifying a target path for files without extension (which already happens anyway, because it copies the file to a folder instead of copying it with the target path file name). So && Path.GetExtension(fileName) != String.Empty would be added in the line before ? targetPath.

@rohit21agrawal
Copy link
Contributor

@jp2masa you are on the right track, i will look forward to a PR from you

@jp2masa
Copy link
Author

jp2masa commented Sep 15, 2017

Unfortunately I won't be able to open a PR today, because I can't debug tests in VS, but I'll repair VS now and open a PR probably tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants