mwiedemeyer / SPDeployment

SPDeployment is a command line tool to deploy all kind of files to SharePoint / Office 365 and set properties if specified.
MIT License
12 stars 5 forks source link

Two watchers in the same source directory not allowed #5

Closed cveld closed 8 years ago

cveld commented 8 years ago

I have a configuration file with two "Sites" which point both to the same site, and both to the same source-directory. The difference is:

  1. Deploy the css-files to the destination folder css
  2. Deploy the js-files to the destination folder js

Unfortunately the current version of the tool uses the value of the source-directory as the key for the filewatchers collection. This results in the following exception:

Stop Error: System.ArgumentException: An item with the same key has already been
 added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boo
lean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at SPDeployment.Deployer.RegisterWatchTask(DeploymentSite site)
   at SPDeployment.Deployer.Deploy(String name, String environment, Boolean watc
h)
mwiedemeyer commented 8 years ago

Please just use one Site element with multiple Files elements. That is an array. See the sample:

"Files": [
        {
          "Source": "dist\\js",
          "Destination": "/js"
        },
        {
          "Source": "dist\\css",
          "Destination": "/css"        
        }
      ]
cveld commented 8 years ago

I see you are proposing a workaround by putting javacripts and css-files in separate folders. Ideally we just keep all files in one flat folder. Currently this is not possible with one Site element given the exception. (using 1.2.4)

mwiedemeyer commented 8 years ago

Well, you can also do this:

"Files": [
        {
          "Source": "dist\\allmyfiles",
          "Destination": "/js",
          "Include": ".*.js"
        },
        {
          "Source": "dist\\allmyfiles",
          "Destination": "/css",
          "Include": ".*.css"        
        }
      ]
cveld commented 8 years ago

Have you tried yourself? I checked the source code and was assuming that the Source-value is used to generate the key for the watcher-object. And due to reuse of the same key the mentioned exception is generated:

Stop Error: System.ArgumentException: An item with the same key has already been
 added.
   at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
   at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boo
lean add)
   at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
   at SPDeployment.Deployer.RegisterWatchTask(DeploymentSite site)
   at SPDeployment.Deployer.Deploy(String name, String environment, Boolean watc
h)