简体   繁体   中英

Azure Pipeline for ASP.NET Webforms WebSite

I have a legacy app on ASP.NET Webforms Website. 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:

    - 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.

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.

it seems like the task is ignoring the properties "/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.

According to the document File Handling During ASP.NET Precompilation :

For executable files in an ASP.NET Web application, the compiler assemblies and files with the .compiled file name extension. The assembly name is generated by the compiler. The .compiled file does not contain executable code. Instead, it contains only the information that ASP.NET needs to find the appropriate assembly.

After the precompiled application is deployed, ASP.NET uses the assemblies in the Bin folder to process requests. The precompilation output includes .aspx or .asmx files as placeholders for pages. 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.

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 .

I would like to share my fix:

I have a legacy app on ASP.NET Webforms Website Project (not WebApp). And this is the setting for Azure Pipeline and the change you have to do in your solutions:

YAML File:

    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:

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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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