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.

Should `dotnet publish` also take the elements specified in "copyToOutput"?

See original GitHub issue

Steps to reproduce

This is more of a design question than a bug, up to the CLI team to decide.

Have an app such as HelloWorldMvc. In its project.json it specifies “copyToOutput”:

    "copyToOutput": {
      "include": [
        "Views",
        "wwwroot"
      ]
    }

When I execute dotnet run it runs fine. When I execute dotnet publish and then dotnet path\to\publish.dll I get runtime errors as the files it required weren’t copied. Shouldn’t the build includes be “inherited” by the publishOptions includes? In the meantime I’ll add:

  "publishOptions": {
    "include": [
      "Views",
      "wwwroot"
    ]
  }

Expected behavior

No need to specify the same stuff twice, unless there’s differences in what’s needed for build and for publish. Publish can be overriden if that’s what’s intended.

Actual behavior

Without “publishOptions” my published app won’t run well, even tough under dotnet run it runs as expected.

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.14295
 OS Platform: Windows
 RID:         win10-x64

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:5
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
andyleejordancommented, Jun 10, 2016

I am definitely desiring an ability to tell either copyToOutput or publishOptions to just inherit the other’s definition. This shouldn’t be an automatic default, but it’d be awesome if we could specify it, say with "publishOptions": { "inherit": "copyToOutput" } or something similar.

As of right now, to update to the new schema, I’m having to duplicate the value of content under both new keys.

0reactions
blackdwarfcommented, Jan 22, 2017

I believe that the desired behavior is now in given the move to MSBuild and csproj. I will close this issue, but please reopen if it still repros with the latest CLI tooling that is based on MSBuild. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core: Exclude or include files on publish
There is a CopyToPublishDirectory attribute for ItemGroup elements that determines whether to copy the file to the publish directory and can ...
Read more >
dotnet publish command - .NET CLI
dotnet publish compiles the application, reads through its dependencies specified in the project file, and publishes the resulting set of files ...
Read more >
Allow CopyToOutputDirectory to have a custom destination ...
For context, I'm trying to "upgrade" my copy logic from the below XML code to use None elements as shown above. The expectation...
Read more >
Copy NuGet Content Files to Output Directory on Build
It turns out, to no surprise, that including content files in a NuGet package will not result in them being automatically copied to...
Read more >
Msbuild get directory name. props imported, or something ...
NET SDK. Project project = new Microsoft. You can pretty much use ... Open the properties of the file and set "Copy to...
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