擴展@Nikolay Balakin的答案,確實不支持使用*.csproj
的.NET Core項目。
您可以通過在託管構建環境中自行安裝最新的.NET核心來解決此問題。
這將允許運行dotnet restore
,dotnet build
,dotnet publish
和dotnet test
。使用Inline powershell extension運行腳本。您可以鏈接到腳本,也可以以行內粘貼文本。我正在運行簽入該項目的腳本。
似乎每個PowerShell腳本會在它自己的環境中運行,所以路徑等不會腳本之間依然存在,因此安裝步驟和構建步驟需要組合成一個腳本。
您需要複製github中的dotnet installation script,並將自己的生成命令添加到最後。
我知道這是不是一個長期的解決方案,但我們通過假設VSTS將在不久的將來支持* .csproj的文件有道理的,我們將轉換爲使用官方的構建任務。
下面是一個示例powershell腳本,顯示了安裝腳本的最後一行以及最後的自定義構建命令。
...
...
Say "Installation finished"
# this is the end of the downloaded script, add your steps after here.
Say "Running dotnet restore AdminPortal\AdminPortal.csproj"
dotnet restore AdminPortal\AdminPortal.csproj
Say "dotnet publish AdminPortal\AdminPortal.csproj --configuration Release"
dotnet publish AdminPortal\AdminPortal.csproj --configuration Release
Say 'Zipping publish file'
$source = $env:BUILD_REPOSITORY_LOCALPATH
$source = $source + '\AdminPortal\bin\Release\net461\publish'
$destination = $env:BUILD_REPOSITORY_LOCALPATH
$destination = $destination + '\AdminPortal\bin\Release\net461\publish.zip'
Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($source, $destination)
Say "Publish finished"
dotnet test "AdminPortal.Tests\AdminPortal.Tests.csproj"
Say "Test finished"
exit 0
來源
2017-03-15 22:09:13
jmc
同樣在這裏。如果我找到解決方案,將回到你身邊。 –
.Net CLI for。csproj項目文件格式和msbuild引擎仍處於預覽版本,它將在功能中可用。建立內部構建代理很容易,您現在可以使用內部構建代理。 –