我用Angular创建了一个asp.net核心项目。因此,它是1个单声道应用程序,而不是两个应用程序。
我的问题如下:
我应该选择部署哪个程序包/文件夹? Dist文件夹或zip文件?还是名为“ artifactnametest”的文件夹?
答案 0 :(得分:1)
您应该改为发布ASP网络核心应用。
这是我们其中一个项目的示例构建文件。这仅适用于asp.net核心。对于有角度的应用程序,我们做了一些额外的工作,例如在不同的任务中运行npm install
,但是原理是相同的。
# ASP.NET Core (.NET Framework)
# Build and test ASP.NET Core projects targeting the full .NET Framework.
# Add steps that publish symbols, save build artifacts, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
trigger:
- master
pool:
vmImage: 'windows-latest'
variables:
solution: '**/*.sln'
buildPlatform: 'Any CPU'
buildConfiguration: 'Release'
runtime: 'win-x64'
steps:
- task: NuGetToolInstaller@1
# Restore all nuget packages and .net core tools
- task: DotNetCoreCLI@2
inputs:
command: 'custom'
projects: '**/*.csproj'
custom: 'restore'
arguments: '-r $(runtime)'
# Build projects
- task: DotNetCoreCLI@2
inputs:
command: 'build'
projects: '**/*.csproj'
arguments: '-c $(BuildConfiguration) --no-restore -r $(runtime)'
# Publish all projects to /staging/ci-build/<ProjectName>/
- task: DotNetCoreCLI@2
inputs:
command: 'publish'
publishWebProjects: false
projects: |
**/*Client.csproj
**/*WorkerService.csproj
**/*Server.csproj
arguments: '-c $(BuildConfiguration) -o $(Build.StagingDirectory)/ci-build --no-build --self-contained -r $(runtime)'
zipAfterPublish: false
# Archive the /staging/ci-build folder to /staging/RemoteData.<BuildNumber>
- task: ArchiveFiles@2
inputs:
rootFolderOrFile: '$(Build.StagingDirectory)/ci-build'
includeRootFolder: false
archiveType: 'zip'
archiveFile: '$(Build.ArtifactStagingDirectory)/RemoteData.$(Build.BuildNumber).zip'
replaceExistingArchive: true
# Publish the zipfile as artifact
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)/RemoteData.$(Build.BuildNumber).zip'
ArtifactName: 'RemoteData.$(Build.BuildNumber)'
publishLocation: 'Container'
答案 1 :(得分:0)
我已经使用Dotnet构建和NPM构建完成了此实现。 首先执行NPM构建并生成一个dist文件夹。然后做一个asp.net构建。构建完成后,将文件复制到Build.artifactstaging目录。 同样,对于NPM dist,将文件夹从工作目录复制到要保留该目录的文件夹中的暂存目录。 然后,您可以压缩整个暂存目录并发布相同的目录。下面是示例代码片段。可以用DotNetCore @ 2任务代替MsBuild
trigger:
branches:
include:
- master
pool:
name: Azure Pipelines
vmImage: 'windows-2019'
demands:
- npm
- msbuild
- visualstudio
variables:
configuration: release
BuildConfiguration: "Release"
platform: x64
stages:
- stage: Build
jobs:
- job: Build
steps:
- task: NuGetToolInstaller@0
displayName: 'Use NuGet 4.4.1'
inputs:
versionSpec: 4.4.1
- task: NuGetCommand@2
displayName: 'NuGet restore'
inputs:
restoreSolution: '$(Parameters.solution)'
vstsFeed: '34356gsgv643a'
- task: Npm@1
displayName: 'npm install'
inputs:
workingDir: angularfoldername
verbose: false
- task: Npm@1
displayName: 'npm custom'
inputs:
command: custom
workingDir: angularfoldername
verbose: false
customCommand: 'run build'
- task: MSBuild@1
displayName: 'Build solution dotnet.csproj'
inputs:
solution: dotnet.csproj
msbuildArguments: '/t:build /p:outputpath="$(build.artifactstagingdirectory)" /property:langversion=latest'
- task: DotNetCoreCLI@2
displayName: Test
inputs:
command: test
projects: '$(Parameters.TestProjects)'
arguments: '--configuration $(BuildConfiguration)'
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)\_PublishedWebsites\dotnet\angularfolder'
inputs:
SourceFolder: 'angularfoldername'
Contents: '**'
TargetFolder: '$(build.artifactstagingdirectory)\_PublishedWebsites\dotnet\angularfoldername'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: drop'
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)\_PublishedWebsites'
答案 2 :(得分:0)
我应该选择部署哪个程序包/文件夹? Dist文件夹或zip文件?还是名为“ artifactnametest”的文件夹?
我同意prasun。我们可以将NPM dist文件夹从工作目录复制到暂存目录,然后压缩整个暂存目录并发布。
或者,我们可以在发布管道中添加两个工件,以部署Dist文件夹和zip文件:
您可以查看此文档Create a build pipeline for Angular and ASP.NET Core apps with Visual Studio Team Services以获得一些详细信息。