0

(somewhat related issue)

TravisCI supports C# builds and Elastic Beanstalk deployments. Cool. But I can't get the Package target to build my zip file that gets deployed into EBS IIS.

My .travis.yml file looks like:

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 --version
Mono JIT compiler version 4.0.1 (tarball Thu May 28 09:08:28 UTC 2015)

The (OK) build message is:

...
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)

The (FAIL) /t:Package message looks like:

...
/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)

So my question is, why Target named 'Package' not found in the project? I've verified /t:Package works fine with MSBuild on a Windows machine.

Note: I've found that if I add an empty target into the .csproj file like

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

It no longer complains about a missing target, but does nothing:

...
/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)

Any xbuild help would be greatly appreciated.

4

1 回答 1

1

所以我的问题是,为什么在项目中找不到名为“包”的目标?我已经验证 /t:Package 在 Windows 机器上与 MSBuild 一起工作正常。

xBuild 不是 MSBuild 的100%替代品。MSBuild 现在已经开源,并且正在做的工作是在 xplat 世界中玩得很好,但它还没有......

因此,当 xbuild 抱怨您的项目中缺少 Package 目标时,那是因为它没有在 xbuild 的“开箱即用”可用的目标中定义。它很可能被编写为 MSBuild 加载/执行的平台相关 dll,并且没有关于他们正在做什么的公开信息,因此在 Xamarin 中从未得到任何关注,和/或没有足够的人需要该功能。加上 /t:package 会创建像“myApp.deploy.cmd”这样的文件,这些文件在 *nix 上不起作用......

因此,您在正确的轨道上,将 Package 目标添加到您的项目并定义您需要它执行的任务,以模拟内置 Web 打包基础结构 Package 在 Windows 上所做的事情,但在 xplat 环境中。我会假设一些消息,路径组合,执行和复制任务来创建/移动 zip 文件。如果您真的需要“myApp.SetParameters.xml”文件,您也可以执行该任务。

“Microsoft.Common.targets”中的 xbuild v12 预定义目标

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 任务(在 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"
于 2015-06-27T05:53:57.840 回答