Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
是否在afterbuild msbuild事件中将文件添加到Azure cspkg?_Msbuild_Azure - Fatal编程技术网

是否在afterbuild msbuild事件中将文件添加到Azure cspkg?

是否在afterbuild msbuild事件中将文件添加到Azure cspkg?,msbuild,azure,Msbuild,Azure,我有一个MVC应用程序,我在Azure上使用它,除了获得已发布的.cspkg文件以包含在后构建过程中创建的css/jscript(如果我发布到不使用Azure的普通服务器上,这会起作用) 在后构建过程中,我缩小并合并文件,然后将它们添加到部署zip: <PackageLocation>..\Deploy\Website.zip</PackageLocation> <PropertyGroup> <CopyAllFilesToSingleFold

我有一个MVC应用程序,我在Azure上使用它,除了获得已发布的.cspkg文件以包含在后构建过程中创建的css/jscript(如果我发布到不使用Azure的普通服务器上,这会起作用)

在后构建过程中,我缩小并合并文件,然后将它们添加到部署zip:

<PackageLocation>..\Deploy\Website.zip</PackageLocation>

<PropertyGroup>
    <CopyAllFilesToSingleFolderForPackageDependsOn>
    CustomCollectFiles;
    $(CopyAllFilesToSingleFolderForPackageDependsOn);
    </CopyAllFilesToSingleFolderForPackageDependsOn>
</PropertyGroup>
。\Deploy\Website.zip
自定义文件;
$(将所有文件复制到SingleFolderForpPackageDependson);

我需要更改哪些MSBuild代码才能执行相同的任务,但需要将其添加到cspkg?

我认为这只是时间安排的问题。。。在执行发布(打包)步骤之前,请确保将文件合并、缩小并放入构建中


对不起,我没有更多的细节;我从未尝试过做这种事。

我就是这样做的。在本例中,我有一个.csproj文件,它是Azure解决方案的一部分,我的C#项目生成的dll需要一个特定的Xml文件,以便在部署中正好位于它旁边。下面是我的.csproj文件中的一些msbuild片段,展示了该技术。您可以将所有这些代码放在.csproj文件中导入Microsoft.CSharp.targets的下面

<!-- Identify the Xml input file that must be deployed next to our dll. -->
<ItemGroup>
  <SpecialXmlFileItem Include="c:\temp\MySpecialFile.xml" />
</ItemGroup>

<PropertyGroup>
  <!-- In my case I needed the as-deployed Xml filename to be fixed and yet I wanted it to be possible
       to provide any filename at all to be provided as the source. Here we are defining the fixed, 
       as-deployed filename. -->
  <AsDeployedXmlFilename>MyServiceStorageConfig.xml</AsDeployedXmlFilename>

  <!-- Wire our own AddFilesToProjectDeployment target into the GetCopyToOutputDirectoryItems
       target. That target is evaluated not only as part of normal .csproj evaluation, but also as part
       of .ccproj evaluation. It is how the .ccproj manages to interrogate your dll producing projects 
       about all of the project files that need to be packaged. -->
  <GetCopyToOutputDirectoryItemsDependsOn>
      AddFilesToProjectDeployment;
      $(GetCopyToOutputDirectoryItemsDependsOn)
  </GetCopyToOutputDirectoryItemsDependsOn>
</PropertyGroup>

<Target Name="AddFilesToProjectDeployment">
  <Error Condition="!Exists('@(SpecialXmlFileItem)')"
      Text="The all important and very special XML file is not found: %(SpecialXmlFileItem.ItemSpec)" />
  <ItemGroup>
    <ContentWithTargetPath Include="@(SpecialXmlFileItem->'%(FullPath)')">
      <!-- In my case I wanted to deploy my xml file right next to my .dll, so I included no relative
      path information in the below value of TargetPath, just the simple filename. But, I think if you
      included relative path information in the below value that it would be preserved in the deployment. -->
      <TargetPath>$(AsDeployedXmlFilename)</TargetPath>
      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </ContentWithTargetPath>
  </ItemGroup>
</Target>

MyServiceStorageConfig.xml
AddFilesToProjectDeployment;
$(GetCopyToOutputDirectoryItemsDependsOn)
$(AsDeployedXmlFilename)
总是

-Bern McCarty

我现在改用Optimization.BundleTable,因此无需在后期构建中手动缩小/合并CSS和JavaScript。