uniblab icon

Rename a content/none file in output dir on build

uniblab | PRO | 02/25/25 06:24:48 PM UTC (Edited) | 0 ⭐ | 6495 👁️ | Never ⏰ | [MSBuild]
XML |

690 B

|

Source Code

|

0 👍

/

0 👎

<?xml version="1.0" encoding="utf-8"?>
<Project Sdk="Microsoft.NET.Sdk">
    <PropertyGroup>
        <AssemblyName>Foo</AssemblyName>
    </PropertyGroup>
    <ItemGroup>
        <Content Include="LICENSE" CopyToOutputDirectory="Always" />
    </ItemGroup>
    <PropertyGroup>
        <!--
            The following will rename the output file LICENSE
            to Foo.License.txt during the build process.
            It leaves the original source file intact,
            and only changes the output file.
            The PostBuildEvent runs in the context of
            $(OutDir)\$(Configuration)\$(TargetFrameworkVersion)
            Ex: bin\Debug\net6.0
        -->
        <PostBuildEvent>
            ren LICENSE $(AssemblyName).License.txt
        </PostBuildEvent>
    </PropertyGroup>
</Project>

Comments

  • uniblab icon
    uniblab PRO
    02/23/25 05:13:45 AM UTC
    text |

    0 B

    |

    0 👍

    /

    0 👎

    FYI: PostBuildEvents run in the context of $(OutDir)\$(Configuration)\$(TargetFrameworkVersion)
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎

    
        
  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎