简体   繁体   English

使用MSBuild Extension Pack和AssemblyInfo自动执行版本号,为什么将其添加到现有项目后会失败?

[英]Using MSBuild Extension Pack and AssemblyInfo to automate the version number, why does it fail when added to an existing project?

I have a large project that consists of several solutions which all contain a mix of unique and shared projects. 我有一个包含多个解决方案的大型项目,所有解决方案都包含独特的项目和共享的项目。

I'm trying to make them all have the same auto-incremented version number when I run my batch build of all of the solutions. 当我运行所有解决方案的批处理版本时,我试图使它们都具有相同的自动递增版本号。

The first two digits need to be fixed, second two auto increment. 前两个数字需要固定,第二个自动递增。

This appears to be the default behaviour of the AssemblyInfo class in the MSBuild Extension Pack 这似乎是MSBuild Extension Pack中AssemblyInfo类的默认行为。

So I've followed the guide here: http://www.msbuildextensionpack.com/help/3.5.12.0/html/d6c3b5e8-00d4-c826-1a73-3cfe637f3827.htm 因此,我在这里遵循了指南: http : //www.msbuildextensionpack.com/help/3.5.12.0/html/d6c3b5e8-00d4-c826-1a73-3cfe637f3827.htm

And I'm mostly getting nowhere. 而且我几乎一无所获。

If I add the following line to a simple, brand new test project: 如果我将以下行添加到一个简单的全新测试项目中:

<Import Project="$(MSBuildExtensionsPath)\ExtensionPack\MSBuild.ExtensionPack.VersionNumber.targets"/>

It works fine. 工作正常。 Every time a build the project in VS it updates the version number. 每次在VS中构建项目时,它都会更新版本号。

However, if I add the exact same line to the first project in my existing solution, I get the following error: 但是,如果将完全相同的行添加到现有解决方案中的第一个项目中,则会出现以下错误:

Unable to update the AssemblyFileVersion for AssemblyInfo.cs: No stub entry for AssemblyFileVersion was found in the AssemblyInfo file.

The contents of AssemblyInfo.cs are: AssemblyInfo.cs的内容是:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("02ecd067-a91c-44bc-a486-a7b097157757")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

Almost entirely identical to the working test version: 与工作测试版本几乎完全相同:

using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("AutoVersionTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Microsoft")]
[assembly: AssemblyProduct("AutoVersionTest")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2013")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: ComVisible(false)]
[assembly: Guid("33c1d540-f9c4-4cc5-86ed-9d8695bf7b4d")]
[assembly: AssemblyVersion("1.0.0103.01")]
[assembly: AssemblyFileVersion("1.0.0103.01")]

So why does it work in one but not the other? 那么,为什么它可以在一个而不是另一个中起作用?

我将确保AssemblyInfo.cs文件实际在项目中,而不是从另一个项目链接进来。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM