I'm attempting to copy a file (coremodule.psd1
) from my project root into the target build directory, however the action is silently failing. The build allegedly succeeds, and my target build output path contains the project DLL, however the coremodule.psd1
file is not copied to the build directory.
nuget.config
.csproj
file with copy taskdotnet restore
dotnet build
โ coremodule tree
.
โโโ Class1.cs
โโโ code.csproj
โโโ coremodule.psd1
โโโ nuget.config
<Project DefaultTargets="CopyFiles" Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard1.6</TargetFramework>
</PropertyGroup>
<ItemGroup>
<PackageReference Include = "Microsoft.PowerShell.SDK" Version = "6.0.0-beta.4" />
</ItemGroup>
<Target Name = "CopyFiles">
<Copy DestinationFolder="$(OutputPath)" SourceFiles="coremodule.psd1" SkipUnchangedFiles = "false" />
</Target>
</Project>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<clear />
<add key="powershell-core" value="https://powershell.myget.org/F/powershell-core/api/v3/index.json" />
<add key="CI Builds (dotnet-core)" value="https://www.myget.org/F/dotnet-core/api/v3/index.json" />
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
</packageSources>
</configuration>
File in project directory is copied to target build / output directory.
File in project directory is not copied to target build / output directory.
dotnet --info
output:
NOTE: This is running inside of a Linux container on Docker for Mac.
root@c00e91a5249a:/code# dotnet --info
.NET Command Line Tools (2.0.0-preview2-006497)
Product Information:
Version: 2.0.0-preview2-006497
Commit SHA-1 hash: 06a2093335
Runtime Environment:
OS Name: debian
OS Version: 9
OS Platform: Linux
RID: linux-x64
Base Path: /usr/share/dotnet/sdk/2.0.0-preview2-006497/
Microsoft .NET Core Shared Framework Host
Version : 2.0.0-preview2-25407-01
Build : 40c565230930ead58a50719c0ec799df77bddee9
Hi pcgeek86,
_dotnet build_ will eventually invoke "build" target. You are adding a target without wire it up to "build"
you can do it like this
<Target Name = "CopyFiles" AfterTargets="build">
<Copy DestinationFolder="$(OutputPath)" SourceFiles="coremodule.psd1" SkipUnchangedFiles = "false" />
</Target>
Most helpful comment
Hi pcgeek86,
_dotnet build_ will eventually invoke "build" target. You are adding a target without wire it up to "build"
you can do it like this