2015-06-26 120 views
0

(有點相關issue是否有xbuild/t:包支持? (TravisCI)

TravisCI支持C#構建和Elastic Beanstalk部署。涼。但是我無法獲取Package目標來構建我的zip文件,該文件被部署到EBS IIS中。

我.travis.yml文件看起來像:

language: csharp 
solution: RestfulWCFService.sln 
mono: 
    - latest 
script: 
    - xbuild RestfulWCFService.sln /p:Configuration=Release /p:Platform="Any CPU" ## OK 
    - xbuild RestfulWCFService.csproj /t:Package /p:Configuration=Release ## FAIL! 
deploy: 
    - provider: elasticbeanstalk 
    .... 

單版本:

$ mono --version 
Mono JIT compiler version 4.0.1 (tarball Thu May 28 09:08:28 UTC 2015) 

的(OK)建立信息是:

... 
Done executing task "CallTarget" 
Done building target "Build" in project "/home/vagrant/syllabus/RestfulWCFService.sln". 
Done building target "Build" in project "/home/vagrant/syllabus/RestfulWCFService.sln" ("/home/vagrant/syllabus/RestfulWCFService.sln"). 
Done building project "/home/vagrant/syllabus/RestfulWCFService.sln". 

Build succeeded. 

Warnings: 

/home/vagrant/syllabus/RestfulWCFService.sln (default targets) -> 
(Build target) -> 
/home/vagrant/syllabus/RestfulWCFService.csproj (default targets) -> 
/usr/lib/mono/4.5/Microsoft.Common.targets (ResolveAssemblyReferences target) -> 

     /usr/lib/mono/4.5/Microsoft.Common.targets: warning : Reference 'System.Web.Entity' not resolved 

     1 Warning(s) 
     0 Error(s) 

的(失敗)/ t:包裝消息看起來像:

... 
/home/vagrant/syllabus/RestfulWCFService.csproj: Importing project /usr/lib/mono/xbuild/Microsoft/VisualStudio/v10.0/WebApplications/Microsoft.WebApplication.targets from extension path /usr/lib/mono/xbuild 
Building target "_ValidateEssentialProperties" in project "/home/vagrant/syllabus/RestfulWCFService.csproj" ("/usr/lib/mono/4.5/Microsoft.Common.targets"). 
Done building target "_ValidateEssentialProperties" in project "/home/vagrant/syllabus/RestfulWCFService.csproj" ("/usr/lib/mono/4.5/Microsoft.Common.targets"). 
/home/vagrant/syllabus/RestfulWCFService.csproj: error : Target named 'Package' not found in the project. 
Done building project "/home/vagrant/syllabus/RestfulWCFService.csproj".-- FAILED 

Build FAILED. 
Errors: 

/home/vagrant/syllabus/RestfulWCFService.csproj (Package) -> 

     /home/vagrant/syllabus/RestfulWCFService.csproj: error : Target named 'Package' not found in the project. 

     0 Warning(s) 
     1 Error(s) 

所以我的問題是,爲什麼Target named 'Package' not found in the project?我已經驗證了/t:Package可以在Windows機器上正常使用MSBuild。

注:我發現,如果我添加一個空的目標到.csproj的文件中像

[Target Name="Package"\] 
[/Target] 

它不再抱怨缺少的目標,但什麼都不做:

... 
/home/vagrant/syllabus/RestfulWCFService.csproj: Importing project /usr/lib/mono/xbuild/Microsoft/VisualStudio/v10.0/WebApplications/Microsoft.WebApplication.targets from extension path /usr/lib/mono/xbuild 
Building target "_ValidateEssentialProperties" in project "/home/vagrant/syllabus/RestfulWCFService.csproj" ("/usr/lib/mono/4.5/Microsoft.Common.targets"). 
Done building target "_ValidateEssentialProperties" in project "/home/vagrant/syllabus/RestfulWCFService.csproj" ("/usr/lib/mono/4.5/Microsoft.Common.targets"). 
Building target "Package" in project "/home/vagrant/syllabus/RestfulWCFService.csproj" ("/home/vagrant/syllabus/RestfulWCFService.csproj"). 
Done building target "Package" in project "/home/vagrant/syllabus/RestfulWCFService.csproj" ("/home/vagrant/syllabus/RestfulWCFService.csproj"). 
Done building project "/home/vagrant/syllabus/RestfulWCFService.csproj". 

Build succeeded. 
     0 Warning(s) 
     0 Error(s) 

任何xbuild幫助將不勝感激。

回答

1

所以我的問題是,爲什麼在 項目中找不到名爲'Package'的Target?我已驗證/ t:軟件包可以在Windows 機器上與MSBuild正常工作。

x構建不是100%替代MSBuild。 MSBuild現在已經開源並且正在努力獲得在xplat世界中玩的不錯,但它還沒有...

所以,當xbuild抱怨你的項目中丟失了Package目標時,那是因爲它沒有在xbuild「開箱即用」的目標中定義。它可能會寫成一個平臺相關的DLL,MSBuild加載/執行,並沒有關於他們在做什麼的公開信息,因此從未得到任何關注Xamarin,和/或沒有足夠的人需要該功能。 Plus/t:軟件包會創建文件,如「myApp.deploy.cmd」,它不適用於* nix ....

因此,您正處於正確的軌道上,向您的項目添加Package目標並定義您需要它來模擬內置Web打包基礎設施包在Windows上執行的操作,但在xplat環境中。我會假設一些消息,路徑組合,執行和複製任務來創建/移動zip文件。如果你真的需要「myApp.SetParameters.xml」文件,你也可以執行。在 「Microsoft.Common.targets」

Target Name="_ValidateEssentialProperties" 
Target Name="PrepareForBuild" DependsOnTargets="$(PrepareForBuildDependsOn)" 
Target Name="AssignLinkMetadata" 
Target Name="GetFrameworkPaths" 
Target Name="GetReferenceAssemblyPaths" DependsOnTargets="$(GetReferenceAssemblyPathsDependsOn)" 
Target Name="GenerateTargetFrameworkMonikerAttribute" 
Target Name="ResolveReferences" DependsOnTargets="$(ResolveReferencesDependsOn)" 
Target Name="BeforeResolveReferences" 
Target Name="AfterResolveReferences" 
Target Name="ResolveAssemblyReferences" DependsOnTargets="$(ResolveAssemblyReferencesDependsOn)" 
Target Name="SplitProjectReferencesByExistent" 
Target Name="_ComputeNonExistentFileProperty" 
Target Name="BuildOnlySettings" 
Target Name="BeforeBuild" 
Target Name="AfterBuild" 
Target Name="Build" DependsOnTargets="$(BuildDependsOn)" Outputs="$(TargetPath)" 
Target Name="BeforeCompile" 
Target Name="AfterCompile" 
Target Name="Compile" DependsOnTargets="$(CompileDependsOn)" 
Target Name="PrepareForRun" DependsOnTargets="$(PrepareForRunDependsOn)" 
Target Name="PrepareResources" DependsOnTargets="$(PrepareResourcesDependsOn)" 
Target Name="SplitResourcesByCulture" DependsOnTargets="AssignTargetPaths" 
Target Name="GenerateSatelliteAssemblies" 
Target Name="DeployOutputFiles" 
Target Name="_CopyDeployFilesToOutputDirectory" 
Target Name="_CopyDeployFilesToOutputDirectoryPreserveNewest" 
Target Name="_CopyDeployFilesToOutputDirectoryAlways" 
Target Name="_CopyAppConfigFile" Condition="'@(AppConfigWithTargetPath)' != ''" 
Target Name="GetTargetPath" Outputs="$(TargetPath)" 
Target Name="GetCopyToOutputDirectoryItems" 
Target Name="PreBuildEvent" 
Target Name="PostBuildEvent" 
Target Name="_TimestampBeforeCompile" Condition="'$(RunPostBuildEvent)' == 'OnOutputUpdated'" 
Target Name="_TimestampAfterCompile" Condition="'$(RunPostBuildEvent)' == 'OnOutputUpdated'" 
Target Name="BeforeRebuild" 
Target Name="AfterRebuild" 
Target Name="Rebuild" 
Target Name="_RecordCleanFile" 
Target Name="_GetCompileOutputsForClean" 
Target Name="_GetCleanFileWrites" 
Target Name="CleanReferencedProjects" 
Target Name="Clean" DependsOnTargets="$(CleanDependsOn)" 
Target Name="BeforeClean" 
Target Name="AfterClean" 
Target Name="CoreClean" DependsOnTargets="_GetCleanFileWrites" 
Target Name="ImplicitlyExpandDesignTimeFacades" 

xbuild任務

xbuild V12預定目標(限定在V12/Microsoft.Build.Tasks。*):

Microsoft.Build.Tasks.AL" 
Microsoft.Build.Tasks.AssignTargetPath" 
Microsoft.Build.Tasks.AssignLinkMetadata" 
Microsoft.Build.Tasks.AssignCulture" 
Microsoft.Build.Tasks.AssignProjectConfiguration" 
Microsoft.Build.Tasks.CallTarget" 
Microsoft.Build.Tasks.CombinePath" 
Microsoft.Build.Tasks.Copy" 
Microsoft.Build.Tasks.CreateCSharpManifestResourceName" 
Microsoft.Build.Tasks.CreateVisualBasicManifestResourceName" 
Microsoft.Build.Tasks.CreateItem" 
Microsoft.Build.Tasks.CreateProperty" 
Microsoft.Build.Tasks.Csc" 
Microsoft.Build.Tasks.Delete" 
Microsoft.Build.Tasks.Error" 
Microsoft.Build.Tasks.Exec" 
Microsoft.Build.Tasks.FindAppConfigFile" 
Microsoft.Build.Tasks.FindUnderPath" 
Microsoft.Build.Tasks.GenerateResource" 
Microsoft.Build.Tasks.GetAssemblyIdentity" 
Microsoft.Build.Tasks.GetFrameworkPath" 
Microsoft.Build.Tasks.GetFrameworkSdkPath" 
Microsoft.Build.Tasks.GetReferenceAssemblyPaths" 
Microsoft.Build.Tasks.LC" 
Microsoft.Build.Tasks.MakeDir" 
Microsoft.Build.Tasks.Message" 
Microsoft.Build.Tasks.MSBuild" 
Microsoft.Build.Tasks.ReadLinesFromFile" 
Microsoft.Build.Tasks.RemoveDir" 
Microsoft.Build.Tasks.RemoveDuplicates" 
Microsoft.Build.Tasks.ResolveAssemblyReference" 
Microsoft.Build.Tasks.SignFile" 
Microsoft.Build.Tasks.Touch" 
Microsoft.Build.Tasks.Vbc" 
Microsoft.Build.Tasks.Warning" 
Microsoft.Build.Tasks.WriteCodeFragment" 
Microsoft.Build.Tasks.WriteLinesToFile"