1
我有一個建立一個類似以下內容:TeamCity的忽略AfterTargets
Test.csproj:(默認的Windows控制檯應用程序,完全沒有變化)
Test.csproj.user:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="Test.csproj.targets" />
</Project>
Test.csproj.targets:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Target Name="AfterCoreCompile" AfterTargets="CoreCompile">
<Message Text="In AfterCoreCompile" />
</Target>
</Project>
使用Visual Studio,輸出如下所示:
------ Build started: Project: Test, Configuration: Debug x86 ------
Build started 8/24/2011 10:48:04 AM.
CoreCompile:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:x86 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /reference:"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\x86\Debug\Test.exe /target:exe Program.cs Properties\AssemblyInfo.cs
AfterCoreCompile:
In AfterCoreCompile
CopyFilesToOutputDirectory:
Copying file from "obj\x86\Debug\Test.exe" to "bin\Debug\Test.exe".
Test -> C:\Users\...\Desktop\Test\Test\bin\Debug\Test.exe
Copying file from "obj\x86\Debug\Test.pdb" to "bin\Debug\Test.pdb".
Build succeeded.
Time Elapsed 00:00:00.09
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
在TeamCity的,它看起來像這樣:
[10:50:05]: Skip checking for changes - there are no VCS roots defined
[10:50:05]: Clearing temporary directory: C:\TeamCity\buildAgent\temp\buildTmp
[10:50:05]: Checkout directory: C:\TeamCity\buildAgent\work\532794d203990edb
[10:50:05]: Repository sources transferred
[10:50:05]: Updating sources: server side checkout...
[10:50:05]: Publishing internal artifacts (4s)
[10:50:09]: [Publishing internal artifacts] Sending build.start.properties file
[10:50:05]: Starting: C:\TeamCity\buildAgent\plugins\dotnetPlugin\bin\JetBrains.BuildServer.MsBuildBootstrap.exe /workdir:C:\Users\buildbot\Desktop\Test /msbuildPath:C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe
[10:50:05]: in directory: C:\Users\buildbot\Desktop\Test
[10:50:06]: Targets was not defined in the build configuration.
[10:50:09]: Test.csproj.teamcity: Build target: Build
[10:50:09]: [Test.csproj.teamcity] CoreCompile
[10:50:09]: [CoreCompile] Csc
[10:50:09]: [Csc] C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702 /nostdlib+ /platform:x86 /errorreport:prompt /warn:4 /define:DEBUG;TRACE /reference:C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorlib.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Core.dll" /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Data.DataSetExtensions.dll" /reference:C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework64\v2.0.50727\System.Xml.dll /reference:"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.5\System.Xml.Linq.dll" /debug+ /debug:full /filealign:512 /optimize- /out:obj\x86\Debug\Test.exe /target:exe Program.cs Properties\AssemblyInfo.cs
[10:50:09]: [Csc] CSC warning CS1607: Assembly generation -- Referenced assembly 'mscorlib.dll' targets a different processor
[10:50:09]: [Csc] CSC warning CS1607: Assembly generation -- Referenced assembly 'System.Data.dll' targets a different processor
[10:50:09]: [Test.csproj.teamcity] CopyFilesToOutputDirectory
[10:50:09]: [CopyFilesToOutputDirectory] Copy
[10:50:09]: [Copy] Copying file from "obj\x86\Debug\Test.exe" to "bin\Debug\Test.exe".
[10:50:09]: [CopyFilesToOutputDirectory] Test.csproj -> C:\Users\Buildbot\Desktop\Test\bin\Debug\Test.exe
[10:50:09]: [CopyFilesToOutputDirectory] Copy
[10:50:09]: [Copy] Copying file from "obj\x86\Debug\Test.pdb" to "bin\Debug\Test.pdb".
[10:50:10]: Process exited with code 0
[10:50:10]: Publishing internal artifacts
[10:50:10]: [Publishing internal artifacts] Sending build.finish.properties file
[10:50:10]: Build finished
那麼,爲什麼TeamCity的無視我的AfterTargets目標?