question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[question] How to copy files to the publish directory post-publish?

See original GitHub issue

Hi everyone, I have the latest version of dotnet from the README page (rc2/preview1) and I’m wondering how to copy files to the publish directory post-build. The reason is I’m looking to change the version of mscorlib that’s used with my app (see dotnet/coreclr#4678) by overwriting the files included with Microsoft.NETCore.App with my copy, as I am contributing to coreclr/corefx.

Anyway, here is my project.json file thus far:

{
    "buildOptions": {
        "copyToOutput": {
            "include": "../../git/coreclr/bin/Product/Windows_NT.x64.Release/**"
        },
        "emitEntryPoint": true
    },
    "dependencies": {
        "Microsoft.NETCore.App": "1.0.0-rc2-*"
    },
    "frameworks": {
        "netcoreapp1.0": {
            "dependencies": {
                "System.Linq": "4.1.0-rc3-*",
                "System.Runtime": "4.1.0-rc3-*",
                "System.Threading.Tasks": "4.0.11-rc3-*"
            },
            "imports": [
                "portable-net45+win8",
                "dnxcore50"
            ]
        }
    },
    "runtimes": {
        "win7-x64": {}
    }
}

copyToOutput doesn’t seem to be working here; instead, it seems to be reproducing the files in <app>/bin/Release/git/coreclr/..., which is not the effect I intended.

I also know you can do something like have "scripts": { "postpublish": { and run shell commands from there, but I’m planning to build this app on another machine, so doing something like

"scripts": {
    "postpublish": [
        "xcopy ../../git/coreclr/bin/Product/Windows_NT.x64.Release/* %publish:OutputPath%"
    ]
}

would work on Windows but not on Linux, if I understand correctly. (It would be nice if we were able to run different shell commands depending on the host OS, e.g. xcopy on Windows and cp on the latter.)

So basically, is there any way to get this done from the project.json and have it work on any OS? Thanks.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
ghostcommented, Dec 9, 2016

include can no longer copy directories with the new .csproj MSBuild project format. What can I do instead?

3reactions
guardrexcommented, Mar 27, 2017

@initiative Copy over the contents of the publish folder.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Copy to Publish Directory output of PreBuild Event
On publish, MsBuild seems to be trying to copy the files in the dist folder that exist before the pre-build event starts.
Read more >
MSBuild Copy Goes To A Different (Incorrect) Location
MSBuild Copy Goes To A Different (Incorrect) Location ... Now the folder Love in Web Project is going to bin\app.publish instead of the...
Read more >
Visual Studio publish to folder is publishing all folders even ...
I've marked many files with 'none' on the build action and 'do not copy' and these are also published. Even the pubxml files...
Read more >
Post-Publish Event - Developer Community
Is it possible to have a post-publish event that can take the copy of the files from my published folder target and then...
Read more >
How to Post-Publish a PDF File when CAD Worker is
Solved: I am trying to create a Windchill Publish Rule that will publish a Creo drawing as a PDF file within a WTDocument....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found