locked
During publish a project how to exclude few files or folder RRS feed

  • Question

  • User-454825017 posted

    we can publish our project to folder. during publishing a project how to exclude few files or folder. is it possible ? if possible then please guide me all the steps i should follow. thanks

    Monday, June 29, 2020 5:45 PM

Answers

  • User288213138 posted

    Hi TDP,

    we can publish our project to folder. during publishing a project how to exclude few files or folder. is it possible ? if possible then please guide me all the steps i should follow. thanks

    You can try to exclude Files and Folders from a Web Package.

    1. Open your solution in Visual Studio.

    2. In the Solution Explorer window, right-click your web application project node (for example, ContactManager.Mvc), point to Add, and then click New Item.

    3. In the Add New Item dialog box, select the XML File template.

    4. In the Name box, type [project name].wpp.targets (for example, ContactManager.Mvc.wpp.targets), and then click Add.

    5. In the file, add a Project element and an ItemGroup element:
      <Project ToolsVersion="4.0" 
               xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
        <ItemGroup>    
        </ItemGroup>
      </Project>
    6. If you want to exclude folders from the web package, add an ExcludeFromPackageFolders element to the ItemGroup element:

      1. In the Include attribute, provide a semicolon-separated list of the folders you want to exclude.

      2. In the FromTarget metadata element, provide a meaningful value to indicate why the folders are being excluded, like the name of the .wpp.targets file.

        <ExcludeFromPackageFolders Include="Internal">
          <FromTarget>ContactManager.Mvc.wpp.targets</FromTarget>
        </ExcludeFromPackageFolders>
    7. If you want to exclude files from the web package, add an ExcludeFromPackageFiles element to the ItemGroup element:

      1. In the Include attribute, provide a semicolon-separated list of the files you want to exclude.

      2. In the FromTarget metadata element, provide a meaningful value to indicate why the files are being excluded, like the name of the .wpp.targets file.

        <ExcludeFromPackageFiles Include="Scripts\jquery-1.4.4-vsdoc.js;Scripts\jquery-1.4.4.js;Scripts\jquery-ui.js;Scripts\jquery.unobtrusive-ajax.js;Scripts\jquery.validate-vsdoc.js;Scripts\jquery.validate.js;Scripts\jquery.validate.unobtrusive.js;Scripts\MicrosoftAjax.debug.js;Scripts\MicrosoftMvcValidation.debug.js">
          <FromTarget>ContactManager.Mvc.wpp.targets</FromTarget>
        </ExcludeFromPackageFiles>
    8. The [project name].wpp.targets file should now resemble this:                
    <Project ToolsVersion="4.0" 
             xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
      <ItemGroup>   
        <ExcludeFromPackageFolders Include="Internal">
          <FromTarget>ContactManager.Mvc.wpp.targets</FromTarget>
        </ExcludeFromPackageFolders>
        <ExcludeFromPackageFiles Include="Scripts\jquery-1.4.4-
    vsdoc.js;Scripts\jquery-1.4.4.js;Scripts\jquery-ui.js;Scripts\jquery.unobtrusive-ajax.js;Scripts\jquery.validate-vsdoc.js;Scripts\jquery.validate.js;Scripts\jquery.validate.unobtrusive.js;Scripts\MicrosoftAjax.debug.js;Scripts\MicrosoftMvcValidation.debug.js">
          <FromTarget>ContactManager.Mvc.wpp.targets</FromTarget>
        </ExcludeFromPackageFiles>
      </ItemGroup>
    </Project>

    9.Save and close the [project name].wpp.targets file.

    The next time you build and package your web application project, the WPP will automatically detect the .wpp.targets file. Any files and folders you specified will not be included in the web package.

    More information about excluding Files and Folders from a Web Package you can refer to this link:

    Excluding Files and Folders from a Web Package

    Best regards,

    Sam

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, June 30, 2020 2:42 AM