Project.json's "copyToOutput" isn't transitive
See original GitHub issueSteps to reproduce
Have ProjectA
which defines a "copyToOutput"
element within its "buildOptions"
section in project.json
. When compiled, the file or files in the "include"
section will be copied to the output, along with ProjectA.dll
.
ProjectA
project.json (“include”: [“ProgramA.cs”] is just as an example)
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true,
"copyToOutput": {
"include": ["ProgramA.cs"]
}
},
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-*"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
ProgramA.cs
using System;
namespace ProjectA
{
public class ClassFromProjectA
{
public int Value { get; set; } = 3;
}
}
Now, have ProjectB
which includes ProjectA
as a reference. When compiled, it will produce ProjectB.dll
as well as ProjectA.dll
in the output directory.
ProjectB
project.json
{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"ProjectA": "1.0.0-*",
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-*"
}
},
"frameworks": {
"netcoreapp1.0": {
"imports": "dnxcore50"
}
}
}
ProgramB.cs
using System;
using ProjectA;
namespace ProjectB
{
public class ProgramB
{
public static void Main(string[] args)
{
var r = new ClassFromProjectA();
Console.WriteLine($"Value from ProjectA {r.Value}");
}
}
}
Expected behavior
The files specified by the "copyToOutput"
element of ProjectA
show up in the output directory of ProjectB
. Furthermore, I expect that the output directory for ProjectA
also contains the files.
Actual behavior
The files included by the "copyToOutput"
element of ProjectA
will not be copied to the output of ProjectB
, or the output directory of ProjectA
. The files will only be copied to the output when the root compilation project is the one specifying the "copyToOutput"
element, and it will only work on the files included by the root compilation project.
Environment data
dotnet --info
output:
.NET Command Line Tools (1.0.0-rc2-002659)
Product Information: Version: 1.0.0-rc2-002659 Commit Sha: 11a001706f
Runtime Environment: OS Name: Windows OS Version: 10.0.14295 OS Platform: Windows RID: win10-x64
Issue Analytics
- State:
- Created 7 years ago
- Reactions:6
- Comments:15 (9 by maintainers)
Yeah when will we expect a fix? Need it.
@xoofx I’m in a really similar situation. It’s caused me to write cross-platform scripts around
dotnet
just to distribute files, when it should be able to pick them up automatically. 😢