【问题标题】:MSBuild target failing on server, yet succeeding locallyMSBuild 目标在服务器上失败,但在本地成功
【发布时间】:2013-05-03 20:45:14
【问题描述】:

对于我们的网络项目,我需要项目的汇编版本来版本我们的静态内容。

我已经在 web 项目文件中声明了一个目标来获取程序集标识并从中检索版本号,例如:

<PropertyGroup>
    <IvanhoWebVersion>
    </IvanhoWebVersion>
  </PropertyGroup>
  <Target Name="SetIvanhoWebVersion" AfterTargets="AfterBuild">
    <Message Text="-----------------">
    </Message>
    <Message Text="Entering target SetIvanhoWebVersion">
    </Message>
    <Message Text="-----------------">
    </Message>
    <GetAssemblyIdentity AssemblyFiles="$(OutputPath)$(AssemblyName).dll">
      <Output TaskParameter="Assemblies" ItemName="AssemblyIdentities" />
    </GetAssemblyIdentity>
    <CreateProperty value="%(AssemblyIdentities.Version)">
      <Output TaskParameter="Value" PropertyName="IvanhoWebVersion" />
    </CreateProperty>
    <Message Text="Assembly version = v$(IvanhoWebVersion)">
    </Message>
    <Exec Command=" &quot;$(SolutionDir)Ivanho.Lib\TranslationGenerator\TranslationGenerator.exe&quot; &quot;$(ProjectDir)Areas\UI\Static\locales\translationsrc\Translations-EN-NL-AR.xlsx&quot; &quot;$(ProjectDir)Areas\UI\Static\locales\v.$(IvanhoWebVersion)&quot;" />
  </Target>

这在本地构建时就像一个魅力,但是当尝试将其签入到我们的 TFS 构建服务器时它会失败并出现以下错误:

无法获取“bin\Ivanho.Web.dll”的程序集名称。无法加载文件 或程序集“Ivanho.Web.dll”或其依赖项之一。系统 找不到指定的路径。

此错误在GetAssemblyIdentity 调用的同一行引发。

我不知道为什么这在构建服务器上不起作用,我对 MSBuild 还是很陌生,有人能指出我正确的方向吗?非常感谢!

【问题讨论】:

    标签: asp.net-mvc-4 msbuild csproj


    【解决方案1】:

    文件不存在或路径错误。 查看构建服务器以查看文件是否存在。您可以使用 converttoabsolutepath 任务来确定路径,请参阅:http://msdn.microsoft.com/en-us/library/bb882668(v=vs.100).aspx。您可以输入错误语句来检查文件,例如

    <Error Condition="!Exists('$(OutputPath)$(AssemblyName).dll')" Text="FileNotFound"/>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-02
      • 2019-06-08
      • 2020-11-12
      相关资源
      最近更新 更多