English 中文(简体)
是否有用于建造日期/时间的MSBuild宏观?
原标题:Is there an MSBuild macro for build date/time?

附录一载有目标部分的建筑文字,如:

    <Target Name="AssemblyVersionMAIN" Inputs="@(AssemblyVersionFiles)" Outputs="UpdatedAssemblyVersionFiles">
        <Attrib Files="%(AssemblyVersionFiles.FullPath)" Normal="true"/>
        <AssemblyInfo
            CodeLanguage="CS"
            OutputFile="%(AssemblyVersionFiles.FullPath)"
            AssemblyProduct="$(ProductName)"
            AssemblyTitle="$(ProductName)"
            AssemblyCompany="$(CompanyName)"
            AssemblyCopyright="© $(CompanyName) 2014"  <!-- THIS LINE -->
            AssemblyVersion="$(Major).$(Minor).$(Build).$(Revision)"
            AssemblyFileVersion="$(Major).$(Minor).$(Build).$(Revision)"
            AssemblyInformationalVersion="$(Major).$(Minor).$(Build).$(Revision)">
            <Output TaskParameter="OutputFile" ItemName="UpdatedAssemblyVersionFiles"/>
        </AssemblyInfo>
    </Target>

目前,这一年是静态的,必须手工改变。 把“2014年”改为“(年)”的方法是否简单? 我检查了MSBuild参考资料,但我没有跳跃。

最佳回答

由于你正在使用Build 4女士,你也可以为此利用财产功能,例如:

<PropertyGroup>
    <CurrentDate>$([System.DateTime]::Now.ToString("yyyy.MM.dd"))</CurrentDate>
</PropertyGroup>

只是按你需要编排受害日期。 还有大量其他职能,见

问题回答

页: 1 采用MSBuild社区任务和MSBuild4,我可以替代如下内容:

AssemblyCopyright="© $(CompanyName) $([System.DateTime]::Now.ToString(`yyyy`))"

这似乎行之有效。





相关问题
How can I overwrite file web.config with web.other.config?

I have a msbuild script with custom logic to deploy my service to the qa server automatically. I have to overwrite the default config with a dedicated one, but when I use <Copy SourceFiles="web....

How do I use MSBuild on a C# project with no compilable code

I have a C# web app project which actually has no ASP.Net or C# in it. It s just a single html page with some Javascript, CSS, and a couple of images. I want to use MSBuild to deploy a version of ...

您能否防止MSBuild.exe经营活动?

我用文字建造一些项目,偶尔利用习俗制造事件,给建筑系统造成了很大困难。 如果有可能,我想援引MSBuild.exe。

building .net applications without Visual Studio

I m interested to hear about people working with building .net applications using MSBuild, NAnt or similar tools. What are you using, why are you using it instead of the VS IDE? I like to use ...

How long does my Visual Studio C# compile take?

It seems like it should be possible to configure Visual Studio to print out how long the compile takes. Perhaps somewhere in the .sln file. If the sln is compiled from the command line using ...

热门标签