Visual Studio 在线 - DevOps
Visual Studio Online - DevOps
我们正在使用 VSO => Azure devops 设置 CI/CD 当前客户端,我需要一些帮助来配置环境中的版本。这是情况和问题。
我已经完成所有构建并正常工作。
我在发布配置中设置了 2 个环境。神器是为掉落而设的。开发环境和 QA 都设置好了。
在 VS2015 中,我为调试、开发、QA 和发布设置了 web.config 转换和配置。 Dev/QA/Release 每个都有一个适用于各自环境的转换。
构建在签入时触发,发布部署在成功构建时正确触发。
Dev 环境和 QA 环境都在发布中正确触发并相应发布。
在每个任务配置中,我都选择了 XML 转换以及正确的部署槽。问题是正在应用的唯一 web.config 转换是发布转换,而不是针对相应环境的正确转换。
我在设置的环境中有 4 个转换配置。
web.config
web.Debug.config
web.Dev.config
web.QA.config
web.Release.config
在 VSO 中,我在发布包中设置了 2 个环境
开发和质量检查
在每个环境中,我都有 XML 转换检查,工具提示指出它将应用 web.Release.config 和每个相应的环境配置。
后者不会发生。
日志:
日志状态:
无法为给定的包应用转换。验证以下内容。
1. Transformation 是否已经在构建过程中应用于 MSBuild 生成的包。如果是,请删除 csproj 文件中每个配置的标记并重建。
2. 确保配置文件和转换文件存在于包内的同一文件夹中。
这两个状态都已确认。如果较新,我已将转换配置设置为复制。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{88941EE6-99FC-4DE5-8FE3-9F532FD855F2}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TripManager</RootNamespace>
<AssemblyName>TripManager</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort>44385</IISExpressSSLPort>
<IISExpressAnonymousAuthentication>disabled</IISExpressAnonymousAuthentication>
<IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
<Use64BitIISExpress />
<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>
<ApplicationInsightsResourceId>/subscriptions/ee4492d7-5913-4e7b-85c0-3915e8c6c5c2/resourcegroups/rg-TripTracker-dev-SC/providers/microsoft.insights/components/TripManager</ApplicationInsightsResourceId>
<WebProject_DirectoryAccessLevelKey>1</WebProject_DirectoryAccessLevelKey>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'QA|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
</Project>
无论转换是否应用于 MSBuild 生成的包,将配置文件添加到压缩包中(如发布日志中的选项 2 所示:确保配置文件和转换文件存在于包内的同一文件夹中) 应该可以工作。
因此您可以在发布工件之前在构建定义中添加配置文件。详细步骤如下:
在 Visual Studio 构建任务之后(发布构建工件之前)和以下任务以提取 zip 文件并在提取文件夹中添加配置文件,然后再次压缩文件:
1.提取文件任务
存档文件模式:$(Build.ArtifactStagingDirectory)\*.zip
目标文件夹:指定解压文件的文件夹,如$(Build.ArtifactStagingDirectory)\test
2。复制文件任务
源文件夹:$(Build.SourcesDirectory)
内容:**\*.config
目标文件夹:提取文件的文件夹,例如$(Build.ArtifactStagingDirectory)\test
3。删除文件任务
源文件夹:$(Build.ArtifactStagingDirectory)
内容:*.zip
(删除由 Visual Studio 构建任务生成的 zip 文件)
4.归档文件任务
要存档的根文件夹(或文件):提取文件的文件夹,例如 $(Build.ArtifactStagingDirectory)\test
存档类型:zip
要创建的存档文件:例如$(Build.ArtifactStagingDirectory)\package.zip
5.删除文件任务
源文件夹:$(Build.ArtifactStagingDirectory)
内容:删除解压文件夹,如test
然后包将部署到 Azure 应用服务并成功发布。
问题是构建结果中不包含配置转换文件。
Ensure that the config file and transformation files are present in
the same folder inside the package.
可以工作,但有一种更简单的方法可以实现:
- 转换文件不应依赖于 web.config。只需在与 web.config 文件相同的目录中创建一个新文件。
- 将转换文件的
Build Action
设置为 Content
。
或只需更改.csproj
文件中的条目:
<None Include="Web.QA.config">
<DependentUpon>Web.config</DependentUpon>
</None>
为此:
<Content Include="Web.QA.config" />
这确保文件在构建后包含在包中。
我们正在使用 VSO => Azure devops 设置 CI/CD 当前客户端,我需要一些帮助来配置环境中的版本。这是情况和问题。
我已经完成所有构建并正常工作。
我在发布配置中设置了 2 个环境。神器是为掉落而设的。开发环境和 QA 都设置好了。
在 VS2015 中,我为调试、开发、QA 和发布设置了 web.config 转换和配置。 Dev/QA/Release 每个都有一个适用于各自环境的转换。
构建在签入时触发,发布部署在成功构建时正确触发。
Dev 环境和 QA 环境都在发布中正确触发并相应发布。
在每个任务配置中,我都选择了 XML 转换以及正确的部署槽。问题是正在应用的唯一 web.config 转换是发布转换,而不是针对相应环境的正确转换。
我在设置的环境中有 4 个转换配置。
web.config
web.Debug.config web.Dev.config web.QA.config web.Release.config
在 VSO 中,我在发布包中设置了 2 个环境
开发和质量检查
在每个环境中,我都有 XML 转换检查,工具提示指出它将应用 web.Release.config 和每个相应的环境配置。
后者不会发生。
日志:
日志状态:
无法为给定的包应用转换。验证以下内容。
1. Transformation 是否已经在构建过程中应用于 MSBuild 生成的包。如果是,请删除 csproj 文件中每个配置的标记并重建。
2. 确保配置文件和转换文件存在于包内的同一文件夹中。
这两个状态都已确认。如果较新,我已将转换配置设置为复制。
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props" Condition="Exists('..\packages\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.1.0.8\build\net45\Microsoft.CodeDom.Providers.DotNetCompilerPlatform.props')" />
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props" Condition="Exists('$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.Default.props')" />
<Import Project="..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props" Condition="Exists('..\packages\Microsoft.Net.Compilers.2.4.0\build\Microsoft.Net.Compilers.props')" />
<Import Project="$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProductVersion>
</ProductVersion>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>{88941EE6-99FC-4DE5-8FE3-9F532FD855F2}</ProjectGuid>
<ProjectTypeGuids>{349c5851-65df-11da-9384-00065b846f21};{fae04ec0-301f-11d3-bf4b-00c04f79efbc}</ProjectTypeGuids>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>TripManager</RootNamespace>
<AssemblyName>TripManager</AssemblyName>
<TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion>
<MvcBuildViews>false</MvcBuildViews>
<UseIISExpress>true</UseIISExpress>
<IISExpressSSLPort>44385</IISExpressSSLPort>
<IISExpressAnonymousAuthentication>disabled</IISExpressAnonymousAuthentication>
<IISExpressWindowsAuthentication>enabled</IISExpressWindowsAuthentication>
<IISExpressUseClassicPipelineMode />
<UseGlobalApplicationHostFile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<TargetFrameworkProfile />
<Use64BitIISExpress />
<TypeScriptToolsVersion>1.8</TypeScriptToolsVersion>
<ApplicationInsightsResourceId>/subscriptions/ee4492d7-5913-4e7b-85c0-3915e8c6c5c2/resourcegroups/rg-TripTracker-dev-SC/providers/microsoft.insights/components/TripManager</ApplicationInsightsResourceId>
<WebProject_DirectoryAccessLevelKey>1</WebProject_DirectoryAccessLevelKey>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Dev|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'QA|AnyCPU'">
<OutputPath>bin\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>AnyCPU</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
</PropertyGroup>
</Project>
无论转换是否应用于 MSBuild 生成的包,将配置文件添加到压缩包中(如发布日志中的选项 2 所示:确保配置文件和转换文件存在于包内的同一文件夹中) 应该可以工作。
因此您可以在发布工件之前在构建定义中添加配置文件。详细步骤如下:
在 Visual Studio 构建任务之后(发布构建工件之前)和以下任务以提取 zip 文件并在提取文件夹中添加配置文件,然后再次压缩文件:
1.提取文件任务
存档文件模式:$(Build.ArtifactStagingDirectory)\*.zip
目标文件夹:指定解压文件的文件夹,如$(Build.ArtifactStagingDirectory)\test
2。复制文件任务
源文件夹:$(Build.SourcesDirectory)
内容:**\*.config
目标文件夹:提取文件的文件夹,例如$(Build.ArtifactStagingDirectory)\test
3。删除文件任务
源文件夹:$(Build.ArtifactStagingDirectory)
内容:*.zip
(删除由 Visual Studio 构建任务生成的 zip 文件)
4.归档文件任务
要存档的根文件夹(或文件):提取文件的文件夹,例如 $(Build.ArtifactStagingDirectory)\test
存档类型:zip
要创建的存档文件:例如$(Build.ArtifactStagingDirectory)\package.zip
5.删除文件任务
源文件夹:$(Build.ArtifactStagingDirectory)
内容:删除解压文件夹,如test
然后包将部署到 Azure 应用服务并成功发布。
问题是构建结果中不包含配置转换文件。
Ensure that the config file and transformation files are present in the same folder inside the package.
- 转换文件不应依赖于 web.config。只需在与 web.config 文件相同的目录中创建一个新文件。
- 将转换文件的
Build Action
设置为Content
。
或只需更改.csproj
文件中的条目:
<None Include="Web.QA.config">
<DependentUpon>Web.config</DependentUpon>
</None>
为此:
<Content Include="Web.QA.config" />
这确保文件在构建后包含在包中。