i would linke to create a nuget package that allows me to add a file.cs during both install and restore phase of nuget package.
This file must be have as build action “C# Compiler”.
I’ve tryed different approach, but nothing succeded. I managed to copy file to the root of target project (as a link) but its build action is just “content”
Any ideas or example?
1
Solved!!
In csproj:
<ItemGroup>
<Compile Update="myfilemyfile.cs">
<Pack>true</Pack>
<BuildAction>Compile</BuildAction>
</Compile>
</ItemGroup>
<ItemGroup>
<None Update="buildmyfile.props">
<Pack>true</Pack>
</None>
</ItemGroup>
In props file
<Compile Include="$(MSBuildThisFileDirectory)..myfilemyfile.cs">
<Link>myfile.cs</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
<BuildAction>Compile</BuildAction>