Advertisement
uniblab

Rename a content/none file in output dir on build

Feb 22nd, 2025 (edited)
331
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | Source Code | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <Project Sdk="Microsoft.NET.Sdk">
  3.     <PropertyGroup>
  4.         <AssemblyName>Foo</AssemblyName>
  5.     </PropertyGroup>
  6.     <ItemGroup>
  7.         <Content Include="LICENSE" CopyToOutputDirectory="Always" />
  8.     </ItemGroup>
  9.     <PropertyGroup>
  10.         <!--
  11.             The following will rename the output file LICENSE
  12.             to Foo.License.txt during the build process.
  13.             It leaves the original source file intact,
  14.             and only changes the output file.
  15.             The PostBuildEvent runs in the context of
  16.             $(OutDir)\$(Configuration)\$(TargetFrameworkVersion)
  17.             Ex: bin\Debug\net6.0
  18.         -->
  19.         <PostBuildEvent>
  20.             ren LICENSE $(AssemblyName).License.txt
  21.         </PostBuildEvent>
  22.     </PropertyGroup>
  23. </Project>
Tags: MSBuild
Advertisement
Comments
  • uniblab
    3 hours
    # text 0.09 KB | 0 0
    1. FYI: PostBuildEvents run in the context of $(OutDir)\$(Configuration)\$(TargetFrameworkVersion)
Add Comment
Please, Sign In to add comment
Advertisement