首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MSBuild.ExtensionPack.Communication.Ftp的FTP凭据

MSBuild.ExtensionPack.Communication.Ftp的FTP凭据
EN

Stack Overflow用户
提问于 2013-12-04 14:18:44
回答 1查看 755关注 0票数 1

在我的AfterBuild脚本中,我使用以下方法将文件上载到部署服务器:

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-04 15:57:36

将这些值放入外部xml文件中。将xml文件中的值读入变量。

Parameters.xml

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<parameters>
  <setParameter name="LineNumber1" value="PeanutsAreCool" />
  <setParameter name="LineNumber2" value="" />
</parameters>

MyMsbuild_MsBuildExtensions.proj

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<Project  ToolsVersion="4.0"  xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped">

 <Import Project="$(MSBuildExtensionsPath)\ExtensionPack\4.0\MSBuild.ExtensionPack.tasks"/>

    <PropertyGroup>
        <!-- Always declare some kind of "base directory" and then work off of that in the majority of cases  -->
        <WorkingCheckout>.</WorkingCheckout>
    </PropertyGroup>

    <Target Name="AllTargetsWrapped">
        <CallTarget Targets="ReadXmlPeekValue" />
    </Target>   


    <Target Name="ReadXmlPeekValue">

        <!--  ReadAttribute  -->
        <MSBuild.ExtensionPack.Xml.XmlFile TaskAction="ReadAttribute" File="$(WorkingCheckout)\Parameters.xml" XPath="/parameters/setParameter[@name='LineNumber1']/@value">
            <Output PropertyName="MyValue1" TaskParameter="Value"/>
        </MSBuild.ExtensionPack.Xml.XmlFile>
        <Message Text="MyValue1 = $(MyValue1)"/>        

    </Target>   

</Project>

MyMsbuild_WithCommunityTasks.proj

代码语言:javascript
复制
<?xml version="1.0" encoding="utf-8"?>
<Project  ToolsVersion="4.0"  xmlns="http://schemas.microsoft.com/developer/msbuild/2003" DefaultTargets="AllTargetsWrapped">

    <!--
  <UsingTask AssemblyFile="$(ProgramFiles)\MSBuild\MSBuild.Community.Tasks.dll" TaskName="Version"/>
  -->



    <Import Project="$(MSBuildExtensionsPath32)\MSBuildCommunityTasks\MSBuild.Community.Tasks.Targets" />



    <PropertyGroup>
        <!-- Always declare some kind of "base directory" and then work off of that in the majority of cases  -->
        <WorkingCheckout>.</WorkingCheckout>
    </PropertyGroup>

    <Target Name="AllTargetsWrapped">
        <CallTarget Targets="ReadXmlPeekValue" />

    </Target>   


    <Target Name="ReadXmlPeekValue">
        <!-- you do not need a namespace for this example, but I left it in for future reference -->
        <XmlPeek Namespaces="&lt;Namespace Prefix='peanutNamespace' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/&gt;"
             XmlInputPath=".\Parameters.xml" 
             Query="/parameters/setParameter[@name='LineNumber1']/@value">
            <Output TaskParameter="Result" ItemName="Peeked" />
        </XmlPeek>

        <Message Text="@(Peeked)"/>

        <XmlPeek Namespaces="&lt;Namespace Prefix='peanutNamespace' Uri='http://schemas.microsoft.com/developer/msbuild/2003'/&gt;"
             XmlInputPath=".\Parameters.xml" 
             Query="/parameters/setParameter[@name='LineNumber1']/@value">
            <Output TaskParameter="Result" PropertyName="PeekedSingle" />
        </XmlPeek>      

        <Message Text="PeekedSingle = $(PeekedSingle)   "/>
    </Target>   






</Project>

编辑:

您可以为这些值添加一些基本错误检查。

请参见此处的URL:

Errors

简单的例子..。注意condition..and是如何检查空字符串的。

代码语言:javascript
复制
    <Error Text="Unable to connect to webserver" Code="Deploy" Condition=" '$(WebURL)' == '' "/>
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20377738

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档