简体   繁体   English

用于 ASP.NET Webforms 网站的 Azure Pipeline

[英]Azure Pipeline for ASP.NET Webforms WebSite

I have a legacy app on ASP.NET Webforms Website.我在 ASP.NET Webforms 网站上有一个遗留应用程序。 The solution is build in Azure Pipeline good so far, but it is ignoring the properties for msbuild task, actually, this is my yaml file for VSBuild task:到目前为止,该解决方案在 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'

And then this is generating .compiled files for each aspx file in my articraft/bin folder.然后这是为我的 articraft/bin 文件夹中的每个 aspx 文件生成.compiled文件。

I do not want to get .compiled files in my bin folder, I want to get only dll of the project in the bin folder.我不想在我的 bin 文件夹中获得 .compiled 文件,我只想在 bin 文件夹中获得项目的 dll。

it seems like the task is ignoring the properties "/p:PrecompileBeforePublish=true /p:EnableUpdateable=true".该任务似乎忽略了属性“/p:PrecompileBeforePublish=true /p:EnableUpdateable=true”。

I do not want to get .compiled files in my bin folder, I want to get only dll of the project in the bin folder.我不想在我的 bin 文件夹中获得 .compiled 文件,我只想在 bin 文件夹中获得项目的 dll。

According to the document File Handling During ASP.NET Precompilation :根据文件处理 ASP.NET 预编译期间的文件:

For executable files in an ASP.NET Web application, the compiler assemblies and files with the .compiled file name extension.对于 ASP.NET Web 应用程序中的可执行文件,编译器程序集和文件扩展名为 .compiled 的文件。 The assembly name is generated by the compiler.程序集名称由编译器生成。 The .compiled file does not contain executable code. .compiled 文件不包含可执行代码。 Instead, it contains only the information that ASP.NET needs to find the appropriate assembly.相反,它只包含 ASP.NET 查找适当程序集所需的信息。

After the precompiled application is deployed, ASP.NET uses the assemblies in the Bin folder to process requests.部署预编译的应用程序后,ASP.NET 使用 Bin 文件夹中的程序集来处理请求。 The precompilation output includes .aspx or .asmx files as placeholders for pages.预编译输出包括 .aspx 或 .asmx 文件作为页面的占位符。 The placeholder files contain no code.占位符文件不包含代码。 They exist only to provide a way to invoke ASP.NET for a specific page request and so that file permissions can be set to restrict access to the pages.它们的存在只是为了提供一种为特定页面请求调用 ASP.NET 的方法,以便可以设置文件权限以限制对页面的访问。

So, we will have to disable the pre-compile steps to remove them.因此,我们将不得不禁用预编译步骤以删除它们。 You just need to change the properties /p:PrecompileBeforePublish=true to /p:PrecompileBeforePublish=false .您只需要将属性/p:PrecompileBeforePublish=true更改为/p:PrecompileBeforePublish=false

I would like to share my fix:我想分享我的修复:

I have a legacy app on ASP.NET Webforms Website Project (not WebApp).我在 ASP.NET Webforms网站项目(不是 WebApp)上有一个遗留应用程序。 And this is the setting for Azure Pipeline and the change you have to do in your solutions:这是 Azure Pipeline 的设置以及您必须在解决方案中进行的更改:

YAML File: 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'

Now you have to update the SLN file and replace this settings for WebSite project:现在您必须更新 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

And the pipelie will generate this artifact:管道将生成这个工件:

artifact神器

this is all!这就是全部!

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

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