【问题标题】:Access Version from AssemblyInfo in MSBuild从 MSBuild 中的 AssemblyInfo 访问版本
【发布时间】:2012-05-29 09:29:21
【问题描述】:

我正在尝试通过 here 解释的 Visual Studio 构建过程创建/推送 nuget 包。

构建包很简单:

<Exec WorkingDirectory="$(ProjectDir)" Command="$(NuGetApp) pack $(ProjectFile) -OutputDirectory $(Deploy) -Verbose -Prop Configuration=Release"/>

我在 $(Deploy) 文件夹中看到 .nupkg 文件。

但是为了能够推送它,我需要 $(AssemblyVersion) 来使用它:

<Exec Command="$(NuGetApp) push $(ProjectName)$(AssemblyVersion) -s $(NugetServer) $(NugetKey)" />

我尝试 XMLRead 来获取值,但 NugetSpecFile 中的值是“$version$”,而不是 AssemblyInfo.cs 中的版本。

<XmlRead XPath="/package/metadata/version" XmlFileName="$(NuSpecFile)">
      <Output TaskParameter="Value" PropertyName="AssemblyVersion" />
    </XmlRead>

如何访问版本以便在“nuget push”中使用它?

【问题讨论】:

    标签: msbuild nuget-package assemblyinfo


    【解决方案1】:

    这个我会做的:

    <PropertyGroup>
        <MyAssemblies>somedll\the.dll</MyAssemblies>
      </PropertyGroup>
    
     <Target Name="RetrieveIdentities">
        <GetAssemblyIdentity
            AssemblyFiles="$(MyAssemblies)">
          <Output
              TaskParameter="Assemblies"
              ItemName="MyAssemblyIdentities"/>
        </GetAssemblyIdentity>
    
        <Message Text="Files: %(MyAssemblyIdentities.Version)"/>
      </Target>
    

    从这里改变: MSBuild Task to read version of dll

    【讨论】:

      猜你喜欢
      • 2017-06-09
      • 2017-10-10
      • 2011-12-06
      • 2018-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多