Skip to content

publish command not copying files to specified output directory #6687

Closed

Description

@deathrowe

Steps to reproduce

"publishOptions": { "include": [ "**/*.json" ] }

dotnet publish --configuration Release --version-suffix 45 --output ./bin/output

Basically just override the default output directory

Expected behavior

new folders should be created in the specified output directory

Actual behavior

only dlls/pdbs are being copied. No new folders are being created.

Environment data

dotnet --info output:
.NET Command Line Tools (1.0.0-preview2-003121)

Product Information:
Version: 1.0.0-preview2-003121
Commit SHA-1 hash: 1e9d529

Runtime Environment:
OS Name: Mac OS X
OS Version: 10.11
OS Platform: Darwin
RID: osx.10.11-x64

I am seeing files copied correctly using the default output directory.

Activity

  1. deathrowe commented on Jul 27, 2016

    @deathrowe
    Author

    Looks to only be an issue if I use a relative path for the output option

  2. brthor commented on Jul 27, 2016

    @brthor
    Contributor
  3. ajaybhargavb commented on Jul 27, 2016

    @ajaybhargavb
    Contributor

    @deathrowe, could you try without the ./?
    dotnet publish --configuration Release --version-suffix 45 --output bin/output/

  4. deathrowe commented on Jul 27, 2016

    @deathrowe
    Author

    ok, without the ./ does work.

    If I try /bin/output I get the error: Access to the path '/bin/output' is denied. Is this expected? I'm guessing so as it looks to be going to the root directory of my drive first

  5. deathrowe commented on Jul 27, 2016

    @deathrowe
    Author

    if I add ../ the folders are not copied/created like I would expect. Only the .dlls and .pdbs are copied. dotnet publish --configuration Release --version-suffix 45 --output ../bin/output/

  6. u-abramchuk commented on Aug 3, 2016

    @u-abramchuk

    Hi, I have the same issue.

    In project.json I have
    "publishOptions": { "includeFiles": [ "appsettings.json", "web.config" ] }

    When running
    dotnet publish or dotnet publish -c Release
    these files are copied to publish folder.

    But when I run
    dotnet publish -o ..\..\output
    they are not copied like I would expect.

  7. severisv commented on Aug 5, 2016

    @severisv

    The error occurs when the target project is not specified as an argument

    Does not work (files specified in publishOptions in project.json are not copied):
    dotnet publish --configuration Release -o myPublishDirectory

    Works:
    dotnet publish --configuration Release -o myPublishDirectory ./

  8. TheRealPiotrP commented on Nov 12, 2016

    @TheRealPiotrP

    I've not been able to repro this after migrating to csproj in preview3. If someone has a csproj repro, please share and reopen!

  9. jonaskello commented on Apr 5, 2017

    @jonaskello

    I have the same issue when using the image microsoft/aspnetcore-build:1.1.1 and running dotnet publish src/MyProj --output out --configuration Release. Running on ubutnu. Nothing gets copied and no error messages.

    EDIT: It works but I was confused by the fact that the output option path is relative to the project path, not the current working dir. Sorry for the noise.

  10. SteveDesmond-ca commented on Apr 21, 2017

    @SteveDesmond-ca
    Contributor

    I just hit this too -- is there documentation anywhere that says that the output dir is relative to the project file, not the current working dir?

  11. urbanhusky commented on May 3, 2017

    @urbanhusky

    The only hint currently is that the defaults are relative to the project.

    dotnet publish -o did not treat relative paths relative to the project but to the current directory in previous versions (migrated from 1.1 preview 2.1)

  12. lantrix commented on Sep 19, 2017

    @lantrix

    @urbanhusky I've also found the same in .NET Core 1.0.

    I migrated from 1.0.2 with SDK Preview 2 build 3148 to the latest full release 1.0.5 with SDK 1.0.4 and the --output also changed from relative to current path to the project path.

    @mairaw will those commits you did on dotnet/docs#3042 also apply to .NET Core 1.0, given that the documentation for dotnet publish currently states it applies to .NET Core 1.x and .NET Core 2.x ?

  13. mairaw commented on Sep 19, 2017

    @mairaw
    Contributor

    that's the change I made @lantrix. But if that's not correct, I'm happy to review that PR. I'm still waiting for review on that one from either @livarcocc or @nguerrera.

  14. dasMulli commented on Sep 19, 2017

    @dasMulli
    Contributor

    I made a last-minute PR (dotnet/cli#7166) but that was too late to get into 2.* so it will have to wait for a major version increment to introduce this now breaking change..

  15. lantrix commented on Sep 25, 2017

    @lantrix

    @mairaw Your documentation change is correct to document current behaviour. I see it is now merged and published too. Thanks!

  16. mairaw commented on Sep 25, 2017

    @mairaw
    Contributor

    cool! Thanks for confirming that @lantrix!

  17. jwbats commented on Nov 7, 2019

    @jwbats

    This issue may have made a comeback in .Net Core 3.

    The following command creates no files in the specified output directory for me:

    dotnet publish ..\..\ -c Debug -r win-x64 -o bin\Debug\PublishOutput

    [Update]

    Never mind, looks like this explains it.

  18. transferred this issue fromdotnet/clion Jan 31, 2020
  19. added a commit that references this issue on Aug 15, 2025
  20. added theissue type on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions