Fody/Costuraを使ったプロジェクトを連続でmsbuildすると失敗する
数日前にFody/Costuraを使った記事を書きました。
で、Fody/Costuraが思いのほか簡単で便利だったので仕事のツールに対応していたら、CI環境(Jenkins)でなぜかビルドエラーになった。
実行順としては
- nuget locals all -clear
- nuget restore
- MSBuild ToolA.sln /m /t:clean,rebuild ~(これは成功)
- nuget locals all -clear
- nuget restore
- MSBuild ToolB.sln /m /t:clean,rebuild ~(これが失敗)
こんな感じ。
で、ToolBのビルド失敗エラーが下記の通り。
MSBUILD : error : Fody: Could not find a weaver named 'Costura'.
MSBUILD : error : If you have nuget package restore turned on you probably need to do a build to download the weavers
MSBUILD : error : Alternatively you may have added a weaver to your 'FodyWeavers.xml' and forgot to add the appropriate NuGet package.
MSBUILD : error : This url may provide more information http://nuget.org/packages/Costura.Fody/ .
ぐぬぬ。わからん。
色々調べてみると、どうやらToolAのmsbuildのプロセスが残っていてFodyのdllを軒並み掴んだままになるため2回目が失敗するということが解りました。
(もしかしたらnugetの取得形式がPackageReferenceの時だけかも)
で、解決策としてはmsbuildの引数に/nr:falseを入れると良いらしい。
↓こんな感じで。
MSBuild ToolA.sln /m /nr:false /t:clean,rebuild ~
teamcity - msbuild.exe staying open, locking files - Stack Overflow
Fody使うと並列ビルドのmsbuildがおかしくなっちゃうんでしょうかね。
とりあえずこれでビルド通ったのでめでたしめでたし。