我在使用nant构建.msbuild上的.vdproj时出现错误。

6

我开始使用asp.net MVC,选择使用.vdproj进行安装设置。但是当我在nant中调用以下命令时:

< exec program="${dotnet.dir}/msbuild.exe" commandline='"./Wum.sln" /v:q /nologo /p:Configuration=Release' />

结果显示:

[exec] D:\My Documents\Visual Studio 2008\Projects\Wum\Wum.sln : warning MSB4078: 项目文件"Wum.Setup\Wum.Setup.vdproj"不受MSBuild支持,无法构建。

有人有任何线索或解决方案吗?如果我使用devenv会有问题吗?

4个回答

10

最近我使用devenv来完成这个操作,因为msbuild无法处理.vdproj文件。这篇文章对于首先更新.vdproj文件非常有帮助: http://www.hanselman.com/blog/BuildingMSIFilesFromNAntAndUpdatingTheVDProjsVersionInformationAndOtherSinsOnTuesday.aspx

<target name="someTarget">
    <!-- full path to setup project and project file (MSI -> vdproj) -->
    <property name="DeploymentProjectPath" value="fullPath\proj.vdproj" />
    <!-- full path to source project and project file (EXE -> csproj) -->
    <property name="DependencyProject" value="fullPath\proj.csproj" />
    <script language="C#">
    <code>
      <![CDATA[
        public static void ScriptMain(Project project)
        {
            //Purpose of script: load the .vdproj file, replace ProductCode and PackageCode with new guids, and ProductVersion with 1.0.SnvRevisionNo., write over .vdproj file

            string setupFileName = project.Properties["DeploymentProjectPath"];
            string productVersion = string.Format("1.0.{0}", project.Properties["svn.revision"]);
            string setupFileContents;

            //read in the .vdproj file          
            using (StreamReader sr = new StreamReader(setupFileName))
            {
                setupFileContents = sr.ReadToEnd();
            }

            if (!string.IsNullOrEmpty(setupFileContents))
            {
                Regex expression2 = new Regex(@"(?:\""ProductCode\"" = \""8.){([\d\w-]+)}");
                Regex expression3 = new Regex(@"(?:\""PackageCode\"" = \""8.){([\d\w-]+)}");
                Regex expression4 = new Regex(@"(?:\""ProductVersion\"" = \""8.)(\d.\d.\d+)");
                setupFileContents = expression2.Replace(setupFileContents,"\"ProductCode\" = \"8:{" + Guid.NewGuid().ToString().ToUpper() + "}");
                setupFileContents = expression3.Replace(setupFileContents,"\"PackageCode\" = \"8:{" + Guid.NewGuid().ToString().ToUpper() + "}");
                setupFileContents = expression4.Replace(setupFileContents,"\"ProductVersion\" = \"8:" + productVersion);

                using (TextWriter tw = new StreamWriter(setupFileName, false))
                {
                    tw.WriteLine(setupFileContents);
                }
            }
        }
       ]]>
    </code>
    </script>

    <!-- must build the dependency first (code project), before building the MSI deployment project -->
    <exec program="Devenv.exe" commandline='"fullPath\solution.sln" /rebuild "Release" /project "${DependencyProject}" /out "fullPath\somelog.log"'/>
    <exec program="Devenv.exe" commandline='"fullPath\solution.sln" /rebuild "Release" /project "${DeploymentProjectPath}" /out "fullPath\somelog.log"'/>
</target>

@GarrisonNeely,你有尝试过像 %DevEnv% "%BaseSln%" /build "%BuildConfiguration%|%BuildPlatform%" /Project "%BaseVdproj%" /Out "vs_errors.txt" 这样的脚本吗? - Kiquenet
适用于 MSBuild 脚本 (*.targets) 吗? - Kiquenet

7

MSBuild无法构建.vdproj项目。您应该使用Visual Studio(devenv.com)进行此操作。


或者从Visual Studio .NET安装和部署项目转移到WiX,因为它将在VS 2010中得到支持。 - The Chairman
为什么 MSBuild 不能构建 .vdproj 项目?MSDN 上有完整的参考资料吗?无论如何,“Wix” 有非常 steed 的 学习曲线 - Kiquenet
@TheChairman Wix有非常大的学习曲线,而微软在VS 2013、VS 2015和VS 2017中提供了Visual Studio安装程序项目的扩展。 - Kiquenet

3

请注意,在.NET 4.0中仍不支持此功能。


1

仅仅是为了扩展CRise的帖子 - 使用命令行通过VS2010 devenv构建vdproj项目是不起作用的。我相信在2010年之前可以正常工作(请参见链接文本


看起来有一些问题,我正在使用2008年的版本。微软已经表示:“热修复程序的当前估计发布时间为八月中旬。” - CRice

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接