dotnet 在代理 407 后面发布
dotnet publish behind proxy 407
我正在尝试设置我的 gitlab 构建服务器以使用 msdeploy 部署 ASP.NET 核心项目。现在的问题是我的部署被代理服务器阻止了...
如何在 dotnet publish
命令中配置代理?
MSDEPLOY : error Code: ERROR_COULD_NOT_CONNECT_TO_REMOTESVC
Error : The remote server returned an error : (407) Proxy Authentication Required.
MSDEPLOY : error count: 1.
这是我目前的命令:
dotnet publish [project.csproj] -c Release /p:PublishProfile="[Location of publish profile]" /p:Password="[Password]"
发布配置文件示例
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>[Url]</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>[Guid]</ProjectGuid>
<MSDeployServiceURL>[URL]</MSDeployServiceURL>
<DeployIisAppPath>DeployProd</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>[Username]</UserName>
<_SavePWD>True</_SavePWD>
<_DestinationType>AzureWebSite</_DestinationType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
您需要指定您的环境变量:
http_proxy = http://user:pass@proxy:port/
https_proxy = http://user:pass@proxy:port/
如果你的 gitlab 不在代理后面,那么你需要排除它:
no_proxy=servername,servername2
然后需要通知msdeploy使用这个代理信息。查找 gitlab runner 使用的 msdeploy.exe 并修改它的 .config 文件。在配置标签之间添加以下内容:
<system.net>
<defaultProxy useDefaultCredentials="true" enabled="true"/>
</system.net>
我正在尝试设置我的 gitlab 构建服务器以使用 msdeploy 部署 ASP.NET 核心项目。现在的问题是我的部署被代理服务器阻止了...
如何在 dotnet publish
命令中配置代理?
MSDEPLOY : error Code: ERROR_COULD_NOT_CONNECT_TO_REMOTESVC
Error : The remote server returned an error : (407) Proxy Authentication Required.
MSDEPLOY : error count: 1.
这是我目前的命令:
dotnet publish [project.csproj] -c Release /p:PublishProfile="[Location of publish profile]" /p:Password="[Password]"
发布配置文件示例
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>[Url]</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>False</ExcludeApp_Data>
<ProjectGuid>[Guid]</ProjectGuid>
<MSDeployServiceURL>[URL]</MSDeployServiceURL>
<DeployIisAppPath>DeployProd</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>[Username]</UserName>
<_SavePWD>True</_SavePWD>
<_DestinationType>AzureWebSite</_DestinationType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<SelfContained>false</SelfContained>
</PropertyGroup>
</Project>
您需要指定您的环境变量:
http_proxy = http://user:pass@proxy:port/
https_proxy = http://user:pass@proxy:port/
如果你的 gitlab 不在代理后面,那么你需要排除它:
no_proxy=servername,servername2
然后需要通知msdeploy使用这个代理信息。查找 gitlab runner 使用的 msdeploy.exe 并修改它的 .config 文件。在配置标签之间添加以下内容:
<system.net>
<defaultProxy useDefaultCredentials="true" enabled="true"/>
</system.net>