无法使用cc.net使用msbuild或aspnet_compiler发布 [英] Unable to publish using msbuild or aspnet_compiler using cc.net

查看:105
本文介绍了无法使用cc.net使用msbuild或aspnet_compiler发布的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在cc.net中自动发布具有许多解决方案的项目.我正在使用msbuild,后者依次调用aspnetcompiler xml文件.问题是我的目录包含许多解决方案,当我运行aspnetcompiler时,出现以下错误.

I am trying to automate publishing a project having many solutions in cc.net. I am using msbuild which in turn calls a aspnetcompiler xml file. Problem is my directory contains many solutions and when I run aspnetcompiler it gives me the following error.

errorASPCONFIG:使用超出应用程序级别注册为allowDefinition ='MachineToApplication'的部分是错误的.此错误可能是由于未将虚拟目录配置为IIS中的应用程序

errorASPCONFIG: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS

我尝试了许多论坛上给出的所有可能的解决方案.但是我很困惑如何显式地告诉aspnet_compiler执行20个项目中的特定项目.

I have tried all possible solutions given at many forums. But I am confused how to explicitly tell aspnet_compiler to execute a particular project out of 20 projects.

  I am using the ccnet build to call aspnet complier 
  <msbuild>
    <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
    <!--msbuild exe directory -->
    <workingDirectory>C:\cc\test\code\</workingDirectory>
    <!--your working directory -->
    <projectFile>C:\Program Files\CruiseControl.NET\server\AspNetCompilerConfiguration.xml</projectFile>
    <!--the configuration xml file which will hold  AspNetCompiler  lines-->
    <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
  </msbuild>

这是我的AspNetCompilerConfiguration.xml文件

this is my AspNetCompilerConfiguration.xml file

<Project
    xmlns = "http://schemas.microsoft.com/developer/msbuild/2003"
    name = "AspNetPreCompile"
    DefaultTargets = "PrecompileWeb">
    <Target Name = "PrecompileWeb">
            <AspNetCompiler
                    VirtualPath = "test" 
                    PhysicalPath = "C:\cc\test\code\"
                    TargetPath = "C:\cc\testitr\deploy\"
                    Force = "true"
                    Debug = "true"
                    Updateable = "true"/>
    </Target>
</Project> 

现在我要运行C:\ cc \ test \ code \ Com.Project1.sln.但我不知道如何告诉ASPNET编译器.任何想法如何执行然后再发布.

Now I want to run C:\cc\test\code\Com.Project1.sln. but i dont know how to tell aspnet compiler. Any idea how to do this and then publish this.

推荐答案

首先:您无法使用aspnet_compiler通过脚本进行网站发布,但是您可以(Release-mode-)编译网站,这通常是相同的.或者,您可以按照我在本文中描述的方式使用MsBuild.

First of all: you can't publish website by scirpt with aspnet_compiler but you can (Release-mode-)compile website which is generally the same thing. Or you can use MsBuild by the way I describe in this post.

我建议您将ASP.NET网站分组到解决方案文件并进行构建.这样您就可以减少参数,并且可以使用Visual Studio测试构建.

I recommend you to group your ASP.NET Websites to solution files and build them. Then you have less params and you can test the build with Visual Studio.

这是在cc.net生成文件中为msbuild-scirpt使用一些参数的方法:

Here is how you can use some params in your cc.net build file for msbuild-scirpt:

  <msbuild>
    <executable>C:\WINDOWS\Microsoft.NET\Framework\v3.5\MSBuild.exe</executable>
    <!--msbuild exe directory -->
    <workingDirectory>C:\cc\test\code\</workingDirectory>
    <!--your working directory -->
    <projectFile>C:\Program Files\CruiseControl.NET\server\AspNetCompilerConfiguration.xml</projectFile>
    <!--the configuration xml file which will hold  AspNetCompiler  lines-->
    <logger>C:\Program Files\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MsBuild.dll</logger>
    <!--Build arguments. You can have multiple projects or msbuild sections in cc.net.config-->
    <buildArgs>/p:Configuration=Debug;MyAttribute1=MyValue1;MyAttribute2=MyValue2;</buildArgs>
    <!--targets, if not default (here PrecompileWeb) -->
    <targets>Build;Analyze</targets>
  </msbuild>

然后,您可以修改AspNetCompilerConfiguration.xml(我认为更好的名称是MyWebSites.msbuild之类的名称)以使用参数:

Then you can modify your AspNetCompilerConfiguration.xml (better name in my opinion would be something like MyWebSites.msbuild) to take params:

<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" name = "AspNetPreCompile"    DefaultTargets = "PrecompileWeb">
  <!--Conditions are params from ccnet.config (or command line)-->
  <PropertyGroup Condition="'$(MyAttribute1)' == MyValue1" >
    <MySolution>c:\mything.sln</MySolution>
  </PropertyGroup>
  <PropertyGroup Condition="'$(MyAttribute1)' != MyValue1" >
    <MySolution>c:\some_other.sln</MySolution>
  </PropertyGroup>

  <!--This way you could import other msbuild-scirpts to manage separate files-->
  <!--<Import Project="Morexml.msbuild"/>-->

  <Target Name="Build">
    <Exec Command="echo hello world 1!"/>
    <MSBuild Projects="$(MySolution)" Targets="Rebuild" ContinueOnError="false" StopOnFirstFailure="false" />
  </Target>
  <Target Name="Analyze">
    <Exec Command="echo hello world 2!"/>
  </Target>
  <!--default, for example, here call some tasks -->
  <!--default is not used when targets are specified -->
  <Target Name="PrecompileWeb">
    <CallTarget Targets="Build" />
    <CallTarget Targets="Analyze" Condition="'$(MyAttribute2)' != 'MyValue2'" />
  </Target>
</Project>

您可以使用Visual Studio或记事本配置解决方案.sln文件.但是它应该有您的网站,如下所示:

You can configure your solution .sln-file with Visual Studio or Notepad. However it should have your websites, something like this:

Project("{ABCD1234-7377-472B-9ABA-BC803B73C123}") = "MyWebSite", "http://localhost/MyWebSite", "{12345678-5FD6-4177-B210-54045B098ABC}"
    ProjectSection(WebsiteProperties) = preProject
        Debug.AspNetCompiler.VirtualPath = "/MyWebSite"
        Debug.AspNetCompiler.PhysicalPath = "..\..\MyWebSite\"
        Debug.AspNetCompiler.TargetPath = "C:\MyPublishedWebsite\"
        Debug.AspNetCompiler.Updateable = "false"
        Debug.AspNetCompiler.ForceOverwrite = "true"
        ...

在那里您可以看到属性.不需要IIS进行任何配置. (只需检查您发布的Web.Config(发行/调试等设置),或者使用一些msbuild-Target即可解决该问题.)

There you can see the properties. There is no need for IIS any configuration. (Just check your released Web.Config (Release/Debug, etc. settings) or maybe use some msbuild-Target to handle that.)

希望这会有所帮助!

这篇关于无法使用cc.net使用msbuild或aspnet_compiler发布的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆