MSBuild不会在bin文件夹中生成dll文件

时间:2019-04-03 08:16:22

标签: xamarin jenkins msbuild nuget jenkins-pipeline

我正在尝试设置Jenkins以自动测试Xamarin项目。我通过jenkinsfile调用MSBuild。输出显示构建成功(请参见下面的阶段日志)。

我的问题是没有bin文件夹和dll被创建(或者我只是找不到它们)。在下一步中,我需要dll来使用NUnit对其进行测试。 dll是否应该在项目文件夹的bin文件夹中创建?

我已经搜索了一天,没有结果。我可能做错了,因为我是Jenkins,MSBuild和Xamarin的新手。我通常使用Visual Studio构建项目。英语不是我的母语,所以很抱歉出现语言错误。

Jenkinsfile(实际的应用名称替换为My_App)

bat "subst \"W:\" /d || exit 0"
bat 'subst W: "%WORKSPACE%"'                 
bat 'C:/nuget.exe restore \"W:/My_App/My_App.sln\"'
bat "\"${tool 'MSBuild'}\" \"W:/My_App/My_App.sln\" /t:Restore /property:Platform=\"Any CPU\" /property:ProductVersion=1.0.0.${env.BUILD_NUMBER}"

Jenkins阶段日志(实际的应用名称替换为My_App)

C:\Program Files (x86)\Jenkins\workspace\My_zorgrobot_development>"C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\MSBuild\15.0\Bin\MSBuild.exe" "W:/My_App/My_App.sln" /t:Restore /property:Platform="Any CPU" /property:ProductVersion=1.0.0.63 
Microsoft (R) Build Engine version 15.9.21+g9802d43bc3 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
Build started 4/3/2019 12:47:25 AM.
Project "W:\My_App\My_App.sln" on node 1 (Restore target(s)).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|Any CPU".
W:\My_App\My_App\My_App.UWP\My_App.UWP.csproj : warning NU1503: Skipping restore for project 'W:\My_App\My_App\My_App.UWP\My_App.UWP.csproj'. The project file may be invalid or missing targets required for restore. [W:\My_App\My_App.sln]
Project "W:\My_App\My_App.sln" (1) is building "W:\My_App\My_App\My_App.Android\My_App.Android.csproj" (2:5) on node 1 (_GenerateProjectRestoreGraph target(s)).
_SetLatestTargetFrameworkVersion:
  Found Java SDK version 1.8.0.
  Found Java SDK version 1.8.0.
Done Building Project "W:\My_App\My_App\My_App.Android\My_App.Android.csproj" (_GenerateProjectRestoreGraph target(s)).
Restore:
  Restoring packages for W:\My_App\My_App\My_App.iOS\My_App.iOS.csproj...
  Restoring packages for W:\My_App\My_App\My_App.Android\My_App.Android.csproj...
  Committing restore...
  Generating MSBuild file W:\My_App\My_App\My_App.Android\obj\My_App.Android.csproj.nuget.g.props.
  Committing restore...
  Generating MSBuild file W:\My_App\My_App\My_App.Android\obj\My_App.Android.csproj.nuget.g.targets.
  Generating MSBuild file W:\My_App\My_App\My_App.iOS\obj\My_App.iOS.csproj.nuget.g.props.
  Writing lock file to disk. Path: W:\My_App\My_App\My_App.Android\obj\project.assets.json
  Generating MSBuild file W:\My_App\My_App\My_App.iOS\obj\My_App.iOS.csproj.nuget.g.targets.
  Writing lock file to disk. Path: W:\My_App\My_App\My_App.iOS\obj\project.assets.json
  Restore completed in 713.65 ms for W:\My_App\My_App\My_App.iOS\My_App.iOS.csproj.
  Restore completed in 696.72 ms for W:\My_App\My_App\My_App.Android\My_App.Android.csproj.
  Restoring packages for W:\My_App\My_App\My_App\My_App.csproj...
  Committing restore...
  Generating MSBuild file W:\My_App\My_App\My_App\obj\My_App.csproj.nuget.g.props.
  Generating MSBuild file W:\My_App\My_App\My_App\obj\My_App.csproj.nuget.g.targets.
  Writing lock file to disk. Path: W:\My_App\My_App\My_App\obj\project.assets.json
  Restore completed in 48.76 ms for W:\My_App\My_App\My_App\My_App.csproj.

  NuGet Config files used:
      C:\Windows\system32\config\systemprofile\AppData\Roaming\NuGet\NuGet.Config
      C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.Offline.config

  Feeds used:
      https://api.nuget.org/v3/index.json
      C:\Program Files (x86)\Microsoft SDKs\NuGetPackages\
Done Building Project "W:\My_App\My_App.sln" (Restore target(s)).

Build succeeded.

"W:\My_App\My_App.sln" (Restore target) (1) ->
(_FilterRestoreGraphProjectInputItems target) -> 
  W:\My_App\My_App\My_App.UWP\My_App.UWP.csproj : warning NU1503: Skipping restore for project 'W:\My_App\My_App\My_App.UWP\My_App.UWP.csproj'. The project file may be invalid or missing targets required for restore. [W:\My_App\My_App.sln]

    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:03.09

Jenkins阶段日志详细度诊断

o_App.Android.csproj (_IsProjectRestoreSupported)  (TaskId:0)
  | 12                : 0.177s           0.177s       W:\My_App\My_App\My_App\My_App.csproj (_GenerateRestoreGraphProjectEntry)  (TaskId:0)
  | 13                : 0.055s           0.055s       W:\My_App\My_App\My_App.Android\My_App.Android.csproj (_GenerateRestoreGraphProjectEntry)  (TaskId:0)
  | 14                : 0.037s           0.037s       W:\My_App\My_App\My_App.iOS\My_App.iOS.csproj (_GenerateRestoreGraphProjectEntry)  (TaskId:0)
  | 15                : 0.030s           0.030s       W:\My_App\My_App.Tests\My_App.Tests.csproj (_GenerateRestoreGraphProjectEntry)  (TaskId:0)
  | 16                : 0.053s           0.053s       W:\My_App\My_App\My_App\My_App.csproj (_GenerateProjectRestoreGraph)  (TaskId:0)
  | 17                : 0.880s           0.880s       W:\My_App\My_App\My_App.Android\My_App.Android.csproj (_GenerateProjectRestoreGraph)  (TaskId:0)
  | 18                : 0.037s           0.037s       W:\My_App\My_App\My_App.iOS\My_App.iOS.csproj (_GenerateProjectRestoreGraph)  (TaskId:0)
  . 19                : 0.032s           0.032s       W:\My_App\My_App.Tests\My_App.Tests.csproj (_GenerateProjectRestoreGraph)  (TaskId:0)

  ============================== Node Utilization (IDs represent configurations) ====================================================
  Timestamp:            1        Duration   Cumulative
  ----------------------------------------------------------------------------------------------------------------------------------- (TaskId:0)
  636898788056711871:   0        0.392s     0.392s ####### (TaskId:0)
  636898788060631956:   1        0.265s     0.657s ##### (TaskId:0)
  636898788063282046:   2        0.136s     0.793s ## (TaskId:0)
  636898788064642119:   3        0.022s     0.815s  (TaskId:0)
  636898788064862126:   4        0.334s     1.149s ###### (TaskId:0)
  636898788068202196:   5        0.074s     1.223s # (TaskId:0)
  636898788068942244:   0        0.018s     1.241s  (TaskId:0)
  636898788069122245:   6        0.062s     1.303s # (TaskId:0)
  636898788069742275:   8        0.034s     1.337s  (TaskId:0)
  636898788070082270:   6        0.003s     1.340s  (TaskId:0)
  636898788070112288:   7        0.027s     1.367s  (TaskId:0)
  636898788070382276:   10       0.136s     1.503s ## (TaskId:0)
  636898788071742310:   7        0.003s     1.506s  (TaskId:0)
  636898788071772332:   9        0.029s     1.535s  (TaskId:0)
  636898788072062334:   0        0.008s     1.543s  (TaskId:0)
  636898788072142348:   11       0.041s     1.584s  (TaskId:0)
  636898788072552328:   0        0.010s     1.594s  (TaskId:0)
  636898788072652360:   12       0.177s     1.771s ### (TaskId:0)
  636898788074422410:   13       0.055s     1.826s # (TaskId:0)
  636898788074972426:   14       0.037s     1.863s  (TaskId:0)
  636898788075342453:   15       0.030s     1.893s  (TaskId:0)
  636898788075642458:   0        0.007s     1.900s  (TaskId:0)
  636898788075712465:   16       0.053s     1.953s # (TaskId:0)
  636898788076242471:   17       0.880s     2.833s ################# (TaskId:0)
  636898788085042751:   18       0.037s     2.870s  (TaskId:0)
  636898788085412761:   19       0.032s     2.902s  (TaskId:0)
  636898788085732751:   0        1.455s     4.357s ############################# (TaskId:0)
  -----------------------------------------------------------------------------------------------------------------------------------
  Utilization:          100.0    Average Utilization: 100.0 (TaskId:0)

Project Evaluation Performance Summary:
       12 ms  W:\My_App\My_App\My_App.UWP\My_App.UWP.csproj   1 calls
       50 ms  W:\My_App\My_App.Tests\My_App.Tests.csproj   1 calls
       62 ms  W:\My_App\My_App\My_App.iOS\My_App.iOS.csproj   1 calls
      175 ms  W:\My_App\My_App\My_App.Android\My_App.Android.csproj   1 calls
      399 ms  W:\My_App\My_App\My_App\My_App.csproj   2 calls

Project Performance Summary:
        6 ms  W:\My_App\My_App\My_App.UWP\My_App.UWP.csproj   1 calls
                  6 ms  _IsProjectRestoreSupported                 1 calls
      112 ms  W:\My_App\My_App.Tests\My_App.Tests.csproj   5 calls
                 23 ms  _IsProjectRestoreSupported                 2 calls
                 29 ms  _GenerateRestoreProjectPathWalk            1 calls
                 30 ms  _GenerateRestoreGraphProjectEntry          1 calls
                 30 ms  _GenerateProjectRestoreGraph               1 calls
      261 ms  W:\My_App\My_App\My_App.iOS\My_App.iOS.csproj   5 calls
                 25 ms  _IsProjectRestoreSupported                 2 calls
                165 ms  _GenerateRestoreProjectPathWalk            1 calls
                 35 ms  _GenerateRestoreGraphProjectEntry          1 calls
                 36 ms  _GenerateProjectRestoreGraph               1 calls
      326 ms  W:\My_App\My_App\My_App\My_App.csproj   8 calls
                 42 ms  _IsProjectRestoreSupported                 2 calls
                 58 ms  _GenerateRestoreProjectPathWalk            4 calls
                175 ms  _GenerateRestoreGraphProjectEntry          1 calls
                 51 ms  _GenerateProjectRestoreGraph               1 calls
     1148 ms  W:\My_App\My_App\My_App.Android\My_App.Android.csproj   5 calls
                123 ms  _IsProjectRestoreSupported                 2 calls
                 99 ms  _GenerateRestoreProjectPathWalk            1 calls
                 46 ms  _GenerateRestoreGraphProjectEntry          1 calls
                880 ms  _GenerateProjectRestoreGraph               1 calls
     4355 ms  W:\My_App\My_App.sln                   1 calls
               4355 ms  Restore                                    1 calls

Target Performance Summary:
        0 ms  CheckForImplicitPackageReferenceOverridesBeforeRestore   1 calls
        0 ms  _GetRestoreSettingsCurrentProject          3 calls
        0 ms  _GetRestoreSettingsOverrides               3 calls
        0 ms  _SetLatestTargetFrameworkVersionForPackageReference   1 calls
        0 ms  _GenerateRestoreProjectPathItemsCurrentProject   5 calls
        0 ms  _GenerateProjectRestoreGraphCurrentProject   4 calls
        0 ms  _GenerateRestoreGraphProjectEntry          4 calls
        0 ms  _GenerateRestoreDependencies               4 calls
        0 ms  ValidateToolsVersions                      1 calls
        0 ms  _GenerateProjectRestoreGraph               4 calls
        0 ms  ValidateProjects                           1 calls
        1 ms  _CheckForUnsupportedNETStandardVersion     1 calls
        1 ms  CollectPackageReferences                   4 calls
        1 ms  _GetRestoreProjectStyle                    4 calls
        2 ms  _GetRestoreSettingsPerFramework            3 calls
        2 ms  _IsProjectRestoreSupported                 4 calls
        4 ms  _GenerateRestoreSpecs                      4 calls
        4 ms  _GenerateRestoreProjectPathItems           5 calls
        5 ms  _GenerateRestoreProjectSpec                4 calls
        5 ms  _GetProjectJsonPath                        4 calls
        8 ms  _GetReferenceAssemblyPaths                 1 calls
        9 ms  _GenerateRestoreProjectPathItemsPerFramework   5 calls
       11 ms  CheckForImplicitPackageReferenceOverrides   1 calls
       20 ms  _GetRestoreTargetFrameworksOutput          4 calls
       22 ms  _GenerateProjectRestoreGraphPerFramework   4 calls
       29 ms  _GenerateDotnetCliToolReferenceSpecs       4 calls
       38 ms  ValidateSolutionConfiguration              1 calls
       40 ms  RedirectMonoAndroidSdkPaths                1 calls
      122 ms  _GetRestoreSettings                        3 calls
      150 ms  _LoadRestoreGraphEntryPoints               1 calls
      185 ms  _GenerateRestoreProjectPathWalk            5 calls
      349 ms  _GetAllRestoreProjectPathItems             1 calls
      826 ms  _SetLatestTargetFrameworkVersion           1 calls
      897 ms  _FilterRestoreGraphProjectInputItems       1 calls
     1323 ms  _GenerateRestoreGraph                      1 calls
     1448 ms  Restore                                    1 calls

Task Performance Summary:
        1 ms  SetVsMonoAndroidRegistryKey                1 calls
        3 ms  GetRestoreProjectJsonPathTask              3 calls
        4 ms  CreateItem                                 2 calls
        5 ms  CreateProperty                             3 calls
        6 ms  CheckForImplicitPackageReferenceOverrides   1 calls
        6 ms  ConvertToAbsolutePath                      8 calls
        7 ms  GetReferenceAssemblyPaths                  1 calls
        9 ms  GetRestorePackageReferencesTask            3 calls
       10 ms  WarnForInvalidProjectsTask                 1 calls
       10 ms  GetRestoreProjectReferencesTask            4 calls
       15 ms  Message                                   10 calls
       16 ms  GetProjectTargetFrameworksTask             4 calls
       20 ms  RemoveDuplicates                          13 calls
       27 ms  GetRestoreDotnetCliToolsTask               4 calls
       32 ms  ResolveAndroidTooling                      1 calls
       77 ms  ResolveSdks                                1 calls
      121 ms  GetRestoreSettingsTask                     3 calls
      131 ms  GetRestoreSolutionProjectsTask             1 calls
      705 ms  ValidateJavaVersion                        1 calls
     1436 ms  RestoreTask                                1 calls
     2724 ms  MsBuild                                   10 calls

Build succeeded.

"W:\My_App\My_App.sln" (Restore target) (1) ->
(_FilterRestoreGraphProjectInputItems target) -> 
  W:\My_App\My_App\My_App.UWP\My_App.UWP.csproj : warning NU1503: Skipping restore for project 'W:\My_App\My_App\My_App.UWP\My_App.UWP.csproj'. The project file may be invalid or missing targets required for restore. [W:\My_App\My_App.sln]

    1 Warning(s)
    0 Error(s)

Time Elapsed 00:00:04.66

作为补充信息,我想补充一下,从MSBuild中删除/ t:Restore会导致构建失败,并说NuGet需要在构建之前还原。

我希望在项目文件夹中的“ bin”文件夹中创建dll文件,但不会创建bin文件夹或dll。

2 个答案:

答案 0 :(得分:0)

您是否尝试过设置参数OutputPath

来自docs

  

指定相对于项目目录的输出目录的路径,例如“ bin \ Debug”。

类似这样的东西:

bat "\"${tool 'MSBuild'}\" \"W:/My_App/My_App.sln\" /t:Restore /property:Platform=\"Any CPU\" /property:OutputPath=W:/output /property:ProductVersion=1.0.0.${env.BUILD_NUMBER}"

您还可以设置/verbosity:Diagnostic来查看它是否还告诉您。

此外,您可以像这样只用一个/property:来编写命令

bat "\"${tool 'MSBuild'}\" \"W:/My_App/My_App.sln\" /t:Restore /property:Platform=\"Any CPU\";OutputPath=W:/output;ProductVersion=1.0.0.${env.BUILD_NUMBER}"

答案 1 :(得分:0)

我看到问题很老,但是最近我在Jenkins服务器上使用MSBuild 16(VS 2019)的FSharp项目遇到了类似的问题。在Jenkins上只有Visual Studio Build Tools 2019。 MSBuild没有生成任何dll文件或bin文件夹。此外,使用/ t:Rebuild选项,会发生另一个错误:项目中不存在目标“ Rebuild”

实际上,就我而言,解决方案很简单。 Visual Studio Build Tools 2019的安装中没有F#编译器,我只是添加了它。 Jenkins是否可能缺少Xamarin构建工具的某些组件?

ps:可能您很久以前就找到了解决方案,但是您自己进行的任何更新都非常适合将来参考:)。