xsp*_*ydr 70 xml asp.net msbuild visual-studio-2010 web-config-transform
所以,我安装了VS 2010,我正在修改我的TeamBuity构建集成的MSBuild脚本.一切都很好,只有一个例外.
如何告诉MSBuild我要应用我在发布构建时创建的Web.conifg转换文件...
我有以下产生编译的网站但它,它将Web.config,Web.Debug.config和Web.Release.config文件(全部3)输出到编译的输出目录.在工作室中,当我执行发布到文件系统时,它将执行转换并仅输出具有适当更改的Web.config ...
<Target Name="CompileWeb">
<MSBuild Projects="myproj.csproj" Properties="Configuration=Release;" />
</Target>
<Target Name="PublishWeb" DependsOnTargets="CompileWeb">
<MSBuild Projects="myproj.csproj"
Targets="ResolveReferences;_CopyWebApplication"
Properties="WebProjectOutputDir=$(OutputFolder)$(WebOutputFolder);
OutDir=$(TempOutputFolder)$(WebOutputFolder)\;Configuration=Release;" />
</Target>
Run Code Online (Sandbox Code Playgroud)
任何帮助都会很棒..!
我知道这可以通过其他方式完成,但我想尽可能使用新的VS 2010方式
Uma*_*aja 63
我一直在寻找类似的信息并且没有找到它,所以我在Visual Studio 2010和MSBuild 4.0附带的.targets文件中进行了一些挖掘.我认为这是寻找将执行转换的MSBuild任务的最佳位置.
据我所知,使用了以下MSBuild任务:
<Project ToolsVersion="4.0"
DefaultTargets="Deploy"
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<UsingTask TaskName="TransformXml"
AssemblyFile="$(MSBuildExtensionsPath)\Microsoft\VisualStudio\v10.0\Web\Microsoft.Web.Publishing.Tasks.dll"/>
<PropertyGroup>
<ProjectPath>C:\Path to Project\Here</ProjectPath>
<DeployPath>C:\Path to Deploy\There</DeployPath>
<TransformInputFile>$(ProjectPath)\Web.config</TransformInputFile>
<TransformFile>$(ProjectPath)\Web.$(Configuration).config</TransformFile>
<TransformOutputFile>$(DeployPath)\Web.config</TransformOutputFile>
<StackTraceEnabled>False</StackTraceEnabled>
</PropertyGroup>
<Target Name="Transform">
<TransformXml Source="$(TransformInputFile)"
Transform="$(TransformFile)"
Destination="$(TransformOutputFile)"
Condition="some condition here"
StackTrace="$(StackTraceEnabled)" />
</Target>
</Project>
Run Code Online (Sandbox Code Playgroud)
我测试了上面的内容,可以确认它是否有效.您可能需要稍微调整一下结构以更好地适应您的构建脚本.
pat*_*onc 13
您应该能够通过使用Package目标并指定临时目录来完成此任务.
msbuild solution.sln /p:Configuration=Release;DeployOnBuild=true;DeployTarget=Package;_PackageTempDir=..\publish
Run Code Online (Sandbox Code Playgroud)
或者,您尝试使用XDT转换工具:
我正在使用它,而不是搞乱晦涩的msbuild目标.使用app.config而不仅仅是web.config.
通过以下更改,它对我有用
<MSBuild Projects="$(ProjectFile)"
Targets="ResolveReferences;_WPPCopyWebApplication"
Properties="WebProjectOutputDir=TempOutputFolder;OutDir=$(WebProjectOutputDir);Configuration=$(Configuration);" />
Run Code Online (Sandbox Code Playgroud)
从MsBuild文件夹下的Microsoft.WebApplication.targets文件
_CopyWebApplication
This target will copy the build outputs along with the
content files into a _PublishedWebsites folder.
This Task is only necessary when $(OutDir) has been redirected
to a folder other than ~\bin such as is the case with Team Build.
The original _CopyWebApplication is now a Legacy, you can still use it by
setting $(UseWPP_CopyWebApplication) to true.
By default, it now change to use _WPPCopyWebApplication target in
Microsoft.Web.Publish.targets.
It allow to leverage the web.config trsnaformation.
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
30699 次 |
| 最近记录: |