Tôi đang làm như sau:Trước và AfterBuild mục tiêu trong Visual Studio không bắn
- Tôi đã tạo ra một dự án tập tin lớp mặc định
- Chỉnh sửa các tập tin csproj bao gồm Pre và Post BuildEvents
- Gỡ bỏ chú mặc định đã nhận xét trước các mục tiêu BeforeBuild và AfterBuild
Mục tiêu BeforeBuild và AfterBuild không được gọi trong biểu mẫu Visual Studio nhưng là từ dòng lệnh msbuild, tại sao vậy?
Tôi thà sử dụng các mục tiêu msbuild thay vì PostBuildEvent như thể mang lại cho tôi nhiều quyền lực và tính linh hoạt hơn, giả sử nó hoạt động.
Chúc mừng,
adam
tôi rút ngắn một số các đường dẫn trong kết quả, vì vậy nếu họ không phù hợp đó là lý do tại sao
ClassLibrary1.csproj thay đổi
kết quả xây dựng của tôi từ VS 2010 là
------ Rebuild All started: Project: ClassLibrary1, Configuration: Debug Any CPU ------
PRE_BUILD
ClassLibrary1 -> c:\ClassLibrary1\bin\Debug\ClassLibrary1.dll
POST_BUILD
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========
và từ dòng lệnh
#>msbuild ClassLibrary1.sln
Microsoft (R) Build Engine Version 4.0.30319.1
[Microsoft .NET Framework, Version 4.0.30319.239]
Copyright (C) Microsoft Corporation 2007. All rights reserved.
Build started 09/05/2012 13:27:42.
Project "c:.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
Building solution configuration "Debug|Any CPU".
Project "c:.sln" (1) is building "c:\ClassLibrary1.csproj" (2) on node 1 (default targets).
BeforeBuild:
### BeforeBuild ###
PreBuildEvent:
echo PRE_BUILD
PRE_BUILD
GenerateTargetFrameworkMonikerAttribute:
Skipping target "GenerateTargetFrameworkMonikerAttribute" because all output files are up-to-date with respect to the input files.
CoreCompile:
Skipping target "CoreCompile" because all output files are up-to-date with respect to the input files.
CopyFilesToOutputDirectory:
ClassLibrary1 -> c:\bin\Debug\ClassLibrary1.dll
PostBuildEvent:
echo POST_BUILD
POST_BUILD
AfterBuild:
### AfterBuild ###
Done Building Project "c:\ClassLibrary1.csproj" (default targets).
Done Building Project "c:.sln" (default targets).
Build succeeded.
0 Warning(s)
0 Error(s)
Time Elapsed 00:00:00.18
cảm ơn, tôi chỉ đang ở giai đoạn thử nghiệm rằng mọi thứ đã làm việc trước khi chuyển sang công việc thực tế tôi đã mong đợi để làm. Tôi sẽ xem xét thay đổi độ dài mặc định –