我們最近已遷移到Visual Studio 2017 Update 2。我們有一個.NET Core 1.1應用程序,它只針對.NET Framework 4.6.1,並且具有項目在同一解決方案中引用.NET Framework類庫。我們正在使用dotnet的1.0.4 SDK版本。使用.NET Core 1.1和新的VS 2017項目格式的dotnet發佈失敗
其中一個項目引用包含配置爲在構建上運行的T4模板。這需要導入Microsoft.TextTemplating.targets
及相關程序集,以便可以通過MSBuild轉換T4模板。這些程序集反過來需要.NET Framework 4.6程序集(System,System.Data,System.Xml等)。
的Visual Studio 2017年沒有問題,構建代碼,然而,當我們試圖在我們的TeamCity建立使用dotnet build
或dotnet publish
,該命令將失敗與以下輸出:根據研究,我
c:\xxx\Microsoft.TextTemplating.targets(340,5): error MSB4018: The "TransformTemplates" task failed unexpectedly. c:\xxx\Microsoft.TextTemplating.targets(340,5): error MSB4018: System.IO.FileNotFoundException: Could not load file or assembly 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified. c:\xxx\Microsoft.TextTemplating.targets(340,5): error MSB4018: File name: 'System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'
到目前爲止,運行T4轉換任務所需的.NET Framework引用沒有被dotnet CLI加載,但它們是由Visual Studio提供的,由於完全獨立的MSBuild工具鏈。
有什麼辦法可以使dotnet publish
的工作方式與Visual Studio相同嗎?這個問題徹底打破了我們的CI/CD列車。我試圖將.NET標準作爲目標框架來檢查它是否可行,但我們使用了幾個不兼容的軟件包,因此這不是一個選項(例如Entity Framework 6.1)。