2017-04-26 89 views
0

我有一个Visual Studio解决方案,包含Azure Web应用程序和一些Azure Web作业。我有一个命令行脚本来发布Azure Web作业。我的问题是,发布脚本构建软件并引入调试DLL而不是发布DLL。Azure Web Job:msbuild:如何在没有调试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中的工作,我有叫构建配置“释放 - 天青”。我可以用这条线做一个纯粹的版本(没有发布):

> 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文件中,我有关于“发布 - Azure”的行。他们是这样的:

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

/P:PublishProfile = “qa-My-sanity - 网络部署”

在发布配置文件文件中,有一个名为LastUsedBuildConfiguration的属性,它将指定构建版本。请将其更改为您需要的任何构建版本。

<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration> 
+0

我说我.pubxml文件,我已经设置了LastUsedBuildConfiguration,它总是设置为“释放 - 天青”,当我们使用Visual Studio的正常工作。 –

+0

由于发布 - Azure是在解决方案文件中定义的,因此在构建项目时无法识别。尝试在发布配置文件中将其修改为“发布”,并将/ p:Configuration = Release添加到msbuild命令中。 – Amor

相关问题