开发者

TeamCity ignores AfterTargets

I have a set up similar to the following:

Test.csproj: (default Windows console application, no changes)

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>

Using Visual Studio, the output looks like this:

------ 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 ==========

In TeamCity it looks like this:

[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\Micros开发者_开发问答oft\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

So why is TeamCity ignoring my AfterTargets targets?


The reason this happened was because the *.csproj.user files are ignored by TeamCity, despite their potential existence in the VCS. Moving the <Import Project="..." /> line into the *.csproj file resulted in the proper behavior.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜