Question

i am working on msbuild scripts and getting below error message

 The "FtpUploadDirectoryContent" task failed unexpectedly.
error MSB4018: System.IO.IOException: The directory name is invalid.

my scripts is

<FtpUploadDirectoryContent
        ServerHost="$(ftpHost)"
        Port="21"
        Username="$(ftpUser)"
        Password="$(ftpPass)"
        LocalDirectory="E:\demo\test.txt"
        RemoteDirectory="website/config"
        Recursive="true"
        />

my IIS hosted path is C:\inetpub\wwwroot and website\config folder is exist inside [C:\inetpub\wwwroot\website\config].but still i am getting message like directory name is invalid.please let me know how to resolve this issue.what is the proper systax for this..pls suggest if any othere thing is required

Était-ce utile?

La solution

LocalDirectory="E:\demo\test.txt"

You gave it a file name, not a directory.

E:\demo\test.txt is a filename.

Here is the code from

https://github.com/loresoft/msbuildtasks/blob/master/Source/MSBuild.Community.Tasks/Ftp/FtpUploadDirectoryContent.cs

            try
            {
                UploadDirectory( LocalDirectory, "*.*", Recursive );
            }
            catch(FtpException caught)
            {
                Log.LogErrorFromException( caught, false );
                Log.LogError( "Couldn't upload directory." );
                return false;
            }


       foreach(string file in Directory.GetFiles( localPath, mask ))
        {
            String filename = Path.GetFileName( file );
            Store( file, filename );

            Log.LogMessage( MessageImportance.Low, "{0} uploaded succesfully.", localPath );
        }

So what you're trying to do is essentially:

 Directory.GetFiles( "E:\demo\test.txt" , "*.* ))

which isn't going to work.

Change it to:

LocalDirectory="E:\demo\"

Example code from the github link above.

/// <Target Name="DeployWebsite">
/// <FtpUploadDirectoryContent
/// ServerHost="ftp.myserver.com"
/// Port="42"
/// Username="user"
/// Password="p@ssw0rd"
/// LocalDirectory="c:\build\mywebsite"
/// RemoteDirectory="root\www\mywebsite"
/// Recursive="true"
/// />

Note: LocalDirectory does not refer to a filename.

If you want to upload a single file, here is a possible alternative:

https://www.assembla.com/spaces/GHFtpTask/wiki/Home/history

The main features of FtpTask for MSBuild are:

**Upload, download or delete a single file on a FTP server** 
Recursively upload, download or delete a directory
Use multiple FTP connections simultaneously

FtpTask for MSBuild requires .NET 2.0.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top