Quantcast
Channel: Category Name
Viewing all articles
Browse latest Browse all 10804

Web Publishing a simpler way to exclude files/folders from being published

$
0
0

I’ve written a fewblog posts on how to exclude files from publishing/packaging. In each of these posts you’d have to be familiar with MSBuild and the Web Publish process. I’ve been looking for a much simpler way to exclude files/folder from publishing.

When using git you can easily exclude files and folders using a .gitignore file. Inside the .gitignore file on each line you can add a pattern that matches files/folders to be excluded from the repository. For example take a look at the sample .gitignore file below.

# Folders to ignore #
OutputRoot/
TestResults/
bin/
obj/
BuildOutput/

# Known files to ignore always #
*.suo
*.user
~*.docx
*.metaproj*

In the .gitignore file above you can see how easy it is to exclude files and folders from publishing.

I thought it would be cool if we had the ability to exclude items from publishing this easily. Now we do!

I’ve created a NuGet package which solves this exact issue. With a web project opened try out the following.

  1. From the Package Manager console execute Install-Package PublishIgnore –pre
  2. Edit the publish.ignore file to add files/folders to be excluded
  3. Publish

You should see that the publish operation skips the files and folders which match the patterns in publish.ignore.

Some notes regarding the implementation here. The publish.ignore file is only supported at the root folder. .gitignore has support to drop .gitignore files in the root as well as subfolders. Currently publish.ignore is not supported in sub folders. This is something that can be implemented if there is enough interest here.

You may be wondering why I named the file “publish.ignore” instead of .publishignore. The reason for this is that on Windows it is difficult to create file names which do not have a string prefixing the extension. You can create these files through the command line, but not through Windows Explorer or VS.

This project is all open source at https://github.com/ligershark/publish-ignore. If you have any problems you can file an issue there, and if you like you can contribute to the code as well!

If this is something that you’d like to see in the box please email me and let us know SayedHa@microsoft.com

 

Thanks,
Sayed Ibrahim Hashimi | @SayedIHashimi


Viewing all articles
Browse latest Browse all 10804

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>