© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
2 replies
RT0405

✅ is there a way to delete or overwrite a dll during the postbuild event?

I'm trying to do some il weaving as a post build event, and I'd like to either overwrite the old dll, or make a new file and delete the old one, however I always get an IOException (another process is using this file) which I presume comes from msbuild still holding onto the file during the postbuild event.
tldr: is there a workaround to allow automatic post build weaving in visual studio that I don't know of or am I missing something

edit: here's my current csproj file, without the library references (if they matter I can add them)
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <AssemblyName>$(MSBuildProjectName)</AssemblyName>
    <TargetName>$(MSBuildProjectName)unweaved</TargetName>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DebugType>embedded</DebugType>
  </PropertyGroup>

    <Target Name="PostBuild" AfterTargets="PostBuildEvent">
        <Exec Command="start ..\Velrdid.OpenXR.PostCompilerFixup\bin\Release\net6.0\Veldrid.OpenXR.PostCompilerFixup.exe" />
    </Target>
</Project>
<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <AssemblyName>$(MSBuildProjectName)</AssemblyName>
    <TargetName>$(MSBuildProjectName)unweaved</TargetName>
  </PropertyGroup>

  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
    <DebugType>embedded</DebugType>
  </PropertyGroup>

    <Target Name="PostBuild" AfterTargets="PostBuildEvent">
        <Exec Command="start ..\Velrdid.OpenXR.PostCompilerFixup\bin\Release\net6.0\Veldrid.OpenXR.PostCompilerFixup.exe" />
    </Target>
</Project>
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

❔ Is there a way to override the DefaultInterpolatedStringHandler?
C#CC# / help
3y ago
✅ Is there a reason to still be using EventArgs and EventHandler<T> for events?
C#CC# / help
17mo ago
✅ is there a way to add a C# event handler to .cshtml button
C#CC# / help
3y ago