我有一个Visual Studio解决方案,包含Azure Web应用程序和一些Azure Web作业。我有一个命令行脚本来发布Azure Web作业。我的问题是发布脚本构建软件并引入调试DLL而不是发布DLL。
> msbuild.exe "c:\git\2\Code\Server\Jobs\Azure\My.Web.Jobs.Number1Script.WebJob\My.Web.Jobs.Number1Script.WebJob.csproj" /p:DeployOnBuild=true /p:PublishProfile="qa-My-sanity - Web Deploy" /p:VisualStudioVersion=14.0 /p:Password="password" /verbosity:minimal /filelogger /flp:logfile=number1_development.log
我认为解决方案文件My.sln包含有关各种编译配置的信息,但它们不在.csproj文件中。
如何配置我的发布,以便调试DLL不会被提取到已发布的软件中?
My.Web.Jobs.Number1Script.WebJob.csproj文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<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>
<ProjectGuid>{1EEB8236-718C-4860-BE73-0E95CB3ABC82}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>My.Web.Jobs.Number1Script.WebJob</RootNamespace>
<AssemblyName>My.Web.Jobs.Number1Script.WebJob</AssemblyName>
<TargetFrameworkVersion>v4.6</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\..\..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<SignAssembly>true</SignAssembly>
</PropertyGroup>
<PropertyGroup>
<AssemblyOriginatorKeyFile>..\..\..\..\..\Certificates\My Corporation.snk</AssemblyOriginatorKeyFile>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x64\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<OutputPath>bin\x64\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x64</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="Microsoft.Azure.KeyVault.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Azure.KeyVault.Core.1.0.0\lib\net40\Microsoft.Azure.KeyVault.Core.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.WebJobs, Version=1.0.1.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Azure.WebJobs.Core.1.0.1\lib\net45\Microsoft.Azure.WebJobs.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Azure.WebJobs.Host, Version=1.0.1.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Azure.WebJobs.1.0.1\lib\net45\Microsoft.Azure.WebJobs.Host.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Edm, Version=5.6.4.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Data.Edm.5.6.4\lib\net40\Microsoft.Data.Edm.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Data.Services.Client, Version=5.6.4.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.Data.Services.Client.5.6.4\lib\net40\Microsoft.Data.Services.Client.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Configuration, Version=1.8.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Microsoft.WindowsAzure.ConfigurationManager.1.8.0.0\lib\net35-full\Microsoft.WindowsAzure.Configuration.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.WindowsAzure.Storage, Version=4.3.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\WindowsAzure.Storage.4.3.0\lib\net40\Microsoft.WindowsAzure.Storage.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\..\..\packages\Newtonsoft.Json.9.0.1\lib\net45\Newtonsoft.Json.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Functions.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
<None Include="packages.config" />
<None Include="Properties\PublishProfiles\qa-My - Web Deploy.pubxml" />
<None Include="Properties\PublishProfiles\qa-My-sanity - Web Deploy.pubxml" />
<None Include="Properties\webjob-publish-settings.json" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\My.Web.Jobs.Number1Script\My.Web.Jobs.Number1Script.csproj">
<Project>{2c99c938-4a66-4bb9-a237-3192428f5618}</Project>
<Name>My.Web.Jobs.Number1Script</Name>
</ProjectReference>
<ProjectReference Include="..\..\My.Web.Jobs\My.Web.Jobs.csproj">
<Project>{b1c602b2-7cb4-489b-9dec-a920f963c8e1}</Project>
<Name>My.Web.Jobs</Name>
</ProjectReference>
<ProjectReference Include="..\My.Web.Jobs.WebJob\My.Web.Jobs.WebJob.csproj">
<Project>{a2c68e89-a4eb-4a07-b8da-384010914104}</Project>
<Name>My.Web.Jobs.WebJob</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 and x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
</Target>
<Import Project="..\..\..\..\packages\Microsoft.Web.WebJobs.Publish.1.0.9\tools\webjobs.targets" Condition="Exists('..\..\..\..\packages\Microsoft.Web.WebJobs.Publish.1.0.9\tools\webjobs.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
当我通过Visual Studio发布作业时,我有一个名为&#34; Release - Azure&#34;的构建配置。我可以使用这一行进行纯构建(不发布):
> msbuild.exe "c:\git\2\Code\My.sln" /fileLogger /verbosity:minimal /p:Configuration='Release - Azure'
当我这样做时,代码被构建,调试DLL没有被拉入。但是如果我使用.csproj文件发布,调试DLL就会被拉入。
我也尝试使用相同的命令发布命令,但后缀为:
/p:Configuration=Release
这给了错误。我试过了:
/p:Configuration="Release - Azure"
这也给出了错误。
在我的My.sln文件中,我有与#34; Release - Azure&#34;相关的行。它们看起来像这样:
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Local|Any CPU = Local|Any CPU
Local|x64 = Local|x64
Local|x86 = Local|x86
Release - Azure|Any CPU = Release - Azure|Any CPU
Release - Azure|x64 = Release - Azure|x64
Release - Azure|x86 = Release - Azure|x86
Release - Windows|Any CPU = Release - Windows|Any CPU
Release - Windows|x64 = Release - Windows|x64
Release - Windows|x86 = Release - Windows|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
有很多部分看起来像:
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxxx}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x64.ActiveCfg = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x64.Build.0 = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x64.Deploy.0 = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x86.ActiveCfg = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x86.Build.0 = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Debug|x86.Deploy.0 = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|Any CPU.ActiveCfg = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|Any CPU.Build.0 = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|Any CPU.Deploy.0 = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x64.ActiveCfg = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x64.Build.0 = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x64.Deploy.0 = Debug|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x86.ActiveCfg = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x86.Build.0 = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Local|x86.Deploy.0 = Debug|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|Any CPU.ActiveCfg = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|Any CPU.Build.0 = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|Any CPU.Deploy.0 = Release|Any CPU
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x64.ActiveCfg = Release|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x64.Build.0 = Release|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x64.Deploy.0 = Release|x64
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x86.ActiveCfg = Release|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x86.Build.0 = Release|x86
{6B1EABD4-433F-4E70-9EFB-xxxxxxxxxxxx}.Release - Azure|x86.Deploy.0 = Release|x86
...
EndGlobalSection
我的.pubxml文件如下所示:
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit http://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release - Azure</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>http://qa-My-sanity.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>False</LaunchSiteAfterPublish>
<MSDeployServiceURL>qa-My-sanity.scm.azurewebsites.net:443</MSDeployServiceURL>
<DeployIisAppPath>qa-My__sanity</DeployIisAppPath>
<SkipExtraFilesOnServer>True</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<UserName>$qa-My__sanity</UserName>
<_SavePWD>True</_SavePWD>
<_DestinationType>AzureWebSite</_DestinationType>
</PropertyGroup>
</Project>
答案 0 :(得分:0)
/ p:PublishProfile =&#34; qa-My-sanity - Web Deploy&#34;
在发布配置文件中,有一个名为LastUsedBuildConfiguration的属性,它将指定构建版本。请将其更改为您想要的任何版本。
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>