开发者

Why visual studio delete non-related assemblies from Bin folder when rebuild

开发者 https://www.devze.com 2023-02-05 05:54 出处:网络
I have an asp.net mvc web application, and i have a reference to SharpArch.Web (one of the Sharp Architecture assemblies)

I have an asp.net mvc web application, and i have a reference to SharpArch.Web (one of the Sharp Architecture assemblies)

When i rebuild the project, and run it, an exception is thrown telling me that the (Newtonsoft.Json.dll) is missing from the Bin folder which is used by (SharpArch.Web), so it's ok, i copied it, and every thing worked well.

开发者_如何学Go

When i try to rebuild the project again, the exception is thrown again, and the (Newtonsoft.Json.dll) assembly is deleted ??

Why did that happen? what does visual studio have to do with non-referenced assembly ? and FYI, VS doesn't delete everything from Bin, just a specific assemblies !!!

and BTW i don't want to add a reference to (Newtonsoft.Json.dll), i don't like to reference an unused assembly.


I had the same situation on one solution I was working on. So I ended up putting those .dll's into a separate folder. In my case I named this folder "ServerAssemblies". Then I modifyed my project file (.csproj in my case) and added an "AfterRebuild" target. That way there is noe need to add references to unused assemblies to the project.

<Target Name="AfterRebuild">
  <ItemGroup>
    <ExtraAssemblies Include="$(SolutionDir)ServerAssemblies\**\*.*"/>
  </ItemGroup>
  <Copy SourceFiles="@(ExtraAssemblies)" DestinationFolder="$(ProjectDir)bin\"></Copy>
</Target>


I suppose that the Bin\ directory is reserved for mangling by Visual Studio. You'll have to put your assembly in a different location.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号