【问题标题】:Azure Pipeline for ASP.NET Webforms WebSiteAzure Pipeline for ASP.NET Webforms 网站
【发布时间】:2020-09-14 23:37:19
【问题描述】:

我在 ASP.NET Webforms 网站上有一个旧版应用程序。到目前为止,该解决方案在 Azure Pipeline 中构建良好,但它忽略了 msbuild 任务的属性,实际上,这是我的 VSBuild 任务的 yaml 文件:

    - task: VSBuild@1
  displayName: Build PowerDetails Web Forms
  inputs:
    solution: '$(solution)'
    msbuildArgs: '/p:PrecompileBeforePublish=true /p:EnableUpdateable=true /p:DebugSymbols=true /p:WDPMergeOption=DonotMerge /p:DeleteExistingFiles=true /p:DeployOnBuild=true /p:SkipInvalidConfigurations=true /p:DeployOnBuild=true /p:WebPublishMethod=FileSystem /p:PackageLocation="$(Build.ArtifactStagingDirectory)"'
    maximumCpuCount: true
    vsVersion: 'latest'

然后这是为我的 articraft/bin 文件夹中的每个 aspx 文件生成 .compiled 文件。

我不想在我的 bin 文件夹中获取 .compiled 文件,我只想在 bin 文件夹中获取项目的 dll。

任务似乎忽略了属性“/p:PrecompileBeforePublish=true /p:EnableUpdateable=true”。

【问题讨论】:

    标签: asp.net azure-devops


    【解决方案1】:

    我不想在我的 bin 文件夹中获取 .compiled 文件,我只想在 bin 文件夹中获取项目的 dll。

    根据文档File Handling During ASP.NET Precompilation

    对于 ASP.NET Web 应用程序中的可执行文件,编译器 具有 .compiled 文件扩展名的程序集和文件。这 程序集名称由编译器生成。 .compiled 文件确实 不包含可执行代码。相反,它只包含信息 ASP.NET 需要找到合适的程序集。

    部署预编译的应用程序后,ASP.NET 使用 Bin 文件夹中的程序集来处理请求。预编译 输出包括 .aspx 或 .asmx 文件作为页面的占位符。这 占位符文件不包含代码。它们的存在只是为了提供一种方法 为特定页面请求调用 ASP.NET,以便该文件 可以设置权限来限制对页面的访问。

    因此,我们将不得不禁用预编译步骤来删除它们。 您只需将属性/p:PrecompileBeforePublish=true 更改为/p:PrecompileBeforePublish=false

    【讨论】:

    • 谢谢,但我做了那个改变,这仍然在 \bin 文件夹中生成 .compiled 文件。
    • @CarlosDev,请分享您是如何获得 bin 文件夹的,只是发布构建工件之类的任务以及您检查 bin 文件夹的位置?
    • 嗨 Leo,这是我的构建任务:-任务:VSBuild@1 输入:解决方案:'$(solution)' msbuildArgs:'/p:DeployOnBuild=true /p:PublishProfile=Azure-Pipele -Profile.pubxml' #'/p:DeployOnBuild=true /p:WebPublishMethod=Package /p:PackageAsSingleFile=true /p:SkipInvalidConfigurations=true /p:PackageLocation="$(build.artifactStagingDirectory)"' 平台:'$( buildPlatform)' 配置:'$(buildConfiguration)'
    • @CarlosDev,感谢您的回复。但是我看不到您在 msbuildArgs 中添加了参数/p:PrecompileBeforePublish=true,我想知道您是如何找到仍在 \bin 文件夹中的 .compiled 文件的?换句话说,你在哪里检查这个 .compiled 文件,从工件?当您使用上面的 msbuild 参数在本地构建项目时,结果如何?
    • 嗨 Leo,我有一个发布工件的任务:- 任务:PublishPipelineArtifact@1 displayName:发布管道工件输入:targetPath:'$(Pipeline.Workspace)'工件:'WinForm_Artifacts ' publishLocation: '管道'
    【解决方案2】:

    我想分享我的修复:

    我在 ASP.NET Webforms 网站 项目(不是 WebApp)上有一个旧版应用程序。这是 Azure Pipeline 的设置以及您必须在解决方案中进行的更改:

    YAML 文件:

        trigger:
    - master
    
    name: $(rev:r)-$(Build.DefinitionName)_$(SourceBranchName)_$(Date:yyyyMMdd)_$(Hours)$(Minutes)$(Seconds)_B-$(BuildID)
    
    pool:
      vmImage: 'windows-latest'
    
    variables:
      solution: '**/*.sln'
      buildPlatform: 'Any CPU'
      buildConfiguration: 'Debug'
    
    steps:
    - task: NuGetToolInstaller@1
      displayName: 'Install Nuget'
    
    - task: NuGetCommand@2
      displayName: 'Nuget Command'
      inputs:
        restoreSolution: '$(solution)'
    
    - task: VSBuild@1
      displayName: Build PowerDetails Web Forms
      inputs:
        solution: '$(solution)'
        msbuildArgs: '/p:ExcludeApp_Data=True /p:PrecompileBeforePublish=True /p:EnableUpdateable=True /p:DebugSymbols=True /p:WDPMergeOption="DonotMerge" /p:WebPublishMethod="FileSystem" /p:PublishProvider="FileSystem" /p:DeleteExistingFiles="True" /p:DeployOnBuild=True /p:PackageLocation="$(Build.ArtifactStagingDirectory)"'
        platform: '$(buildPlatform)'
        configuration: '$(buildConfiguration)'
        maximumCpuCount: true
        vsVersion: 'latest'
    - task: PublishPipelineArtifact@1
      displayName: Publish Pipeline Artifact
      inputs:
        targetPath: '$(Pipeline.Workspace)'
        artifact: 'WinForm_Artifacts'
        publishLocation: 'pipeline'
    

    现在您必须更新 SLN 文件并为网站项目替换此设置:

    Project("{E24C65DC-7377-472B-9ABA-BC803B73C61A}") = "WebSite1", "http://localhost:8080", "{BF5B70E3-DC4C-4AE4-BCD8-D0B5D3A6AA66}"
    ProjectSection(WebsiteProperties) = preProject
        SccProjectName = "SAK"
        SccAuxPath = "SAK"
        SccLocalPath = "SAK"
        SccProvider = "SAK"
        UseIISExpress = "true"
        TargetFrameworkMoniker = ".NETFramework,Version%3Dv4.6.1"
        ProjectReferences = "{ba89722c-1b24-4da4-b963-0df5cf17af21}|PowerDetail.Web.dll;"
        Debug.AspNetCompiler.Clean = "true"
        Debug.AspNetCompiler.Force = "true"
        Debug.AspNetCompiler.VirtualPath = "/drop"
        Debug.AspNetCompiler.PhysicalPath = "WebSite\"
        Debug.AspNetCompiler.TargetPath = "..\..\temp\drop\"
        Debug.AspNetCompiler.Updateable = "true"
        Debug.AspNetCompiler.ForceOverwrite = "true"
        Debug.AspNetCompiler.FixedNames = "false"
        Debug.AspNetCompiler.Debug = "true"
        Release.AspNetCompiler.Clean = "true"
        Release.AspNetCompiler.Force = "true"
        Release.AspNetCompiler.VirtualPath = "/drop"
        Release.AspNetCompiler.PhysicalPath = "WebSite\"
        Release.AspNetCompiler.TargetPath = "..\..\temp\drop\"
        Release.AspNetCompiler.Updateable = "true"
        Release.AspNetCompiler.ForceOverwrite = "true"
        Release.AspNetCompiler.FixedNames = "false"
        Release.AspNetCompiler.Debug = "true"
    
    
        SlnRelativePath = "WebSite\"
        EndProjectSection
    EndProject
    

    管道会生成这个工件:

    artifact

    就这些了!

    【讨论】:

      猜你喜欢
      • 2021-06-18
      • 1970-01-01
      • 1970-01-01
      • 2011-04-03
      • 1970-01-01
      • 2012-07-25
      • 1970-01-01
      • 2018-01-15
      • 2010-10-05
      相关资源
      最近更新 更多