我有一個項目A與依賴項B通過nuget。依賴B來自另一個團隊,超出了我的直接控制範圍。在構建後覆蓋nuget包的依賴關係
B的nuget包含B的依賴關係,包括Common.Logging v1.2。這是通過B的nuget目標文件(類似於<Copy SourceFiles='@(PackageBManagedFiles)' DestinationFolder="$(TargetDir)\"/>
)
複製到位。碰巧,我還需要對項目A中的Common.Logging進行引用,但後來的版本爲3.0。我已經添加了這個使用nuget和參考在Visual Studio 看起來好的。
,因爲我需要Common.Logging的兩個版本,我增加了一個assemblyBinding
到app.config文件,是這樣的:
<dependentAssembly>
<assemblyIdentity name="Common.Logging" publicKeyToken="xxx" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
</dependentAssembly>
所以最好我想Common.Logging的3.0版本是在我的bin目錄中。
但是,版本1.2最終在我的bin目錄中 - 因此應用程序不起作用。
我試圖重寫回版本3.0使用後生成事件。在後期構建事件(類似於dir $(TargetDir) > dir.txt
)中回顯bin目錄的內容到文件表明文件副本已經起作用,但是到構建完成時,文件的舊版本已恢復到位。
這表明,構建的順序如下:
依賴複製到位
後生成事件運行
的NuGet目標文件運行程序包B
這表明我可以cr使用Common.Logging 3.0包含一個目標文件,以便將新的3.0 dll複製到舊的1.2 dll文件的頂部 - 但前提是我可以保證nuget包/目標文件的運行順序。
任何想法如何在構建後將Common.Logging 3.0放入我的bin目錄中?