我正在自定義一個.csproj
項目,在主構建之前運行一些自定義任務。但是,我無法完成任務的執行。MS-Build BeforeBuild not firing
我取消註釋.csproj
文件中的<Target Name="BeforeBuild" />
元素並添加了一個簡單的消息任務,但是當我構建時,消息不會顯示在我的輸出中,因此看起來任務未運行。所以這個片段不會輸出消息。
清單1:沒有消息顯示
<Target Name="BeforeBuild">
<Message Text="About to build ORM layer" Importance="normal" />
</Target>
但是,如果我有一些屬性的螺絲,我可以得到.csproj
失敗在所有執行;
清單2:一個MSBuild配置錯誤
<Target Name="BeforeBuild">
<Message Text="About to build ORM layer" XXImportance="normal" />
</Target>
注意XXImportance
屬性。生成錯誤我得到的是
My.csproj(83,46): error MSB4064: The "XXImportance" parameter is not supported by the "Message" task. Verify the parameter exists on the task, and it is a settable public instance property.
這表明XML被解析,該Message
類已經發現,那類被反映在了可用的屬性。
爲什麼該任務不能執行?
我使用3.5框架。
更新1:在@ Martin的建議,我試圖在控制檯上運行MSBuild,並得到這個錯誤;
c:\path\to\my.csproj(74,11): error MSB4019: The imported
project "C:\Microsoft.CSharp.targets" was not found. Confirm
that the path in the <Import> declaration is correct, and that
the file exists on disk.
74行讀取;
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
更新2:我編譯VS2008中,它使用C#編譯器3,但我編譯該項目是一個框架2.0的項目。當從命令行運行時(請參閱UPDATE 1),構建似乎失敗,因爲對於指定Microsoft.CSharp.targets
文件的位置存在混淆。
嗨,馬丁。非常感謝答覆 - 我很感激。 我已經在最小程度上,所以我不認爲這是。 我試着編譯通過控制檯,但得到一個錯誤 - 我已經將它附加到原始文章。有任何想法嗎? – 2010-07-28 12:26:44
您是否在開始菜單 - >所有程序中使用Visual Studio工具(位於Microsfot Vistual Studio 20xx下)下的Visual Stuido命令Pront。它設置了一系列使msbuild工作的環境變量。 – 2010-07-28 12:37:50
另外,你可以試試。正常,而不是最小 – 2010-07-28 12:38:39