none
"The "CreateSqlUser" task was not given a value in the required parameter "UserName"

    Question

  • The Publish process ends with the error message 'The "CreateSqlUser" task was not given a value in the required parameter "UserName"'.
    Where does CreateSqlUser expect to get a value for the parameter UserName?

    Environment:
    OS: Windows Web Server 2008 R2 SP1 x64
    VS 2010, LightSwitch 2011

    SQL Server 2008 R2 
    The Data Source is a database in use also by other production applications;  works OK.
    I am the Admin of the server and I have access to it via Remote Desktop Connection.
    I publish the app with the following parameters:
    Desktop
    Where will services be hosted: Local
    Administrator connection: 
    Data Source=S15564869\SQLEXPRESS;Initial Catalog=BSDmanager;Integrated Security=True;Pooling=True;Connect Timeout=30;User Instance=False
    User connection:
    Data Source=S15564869\SQLEXPRESS;Initial Catalog=BSDmanager;Integrated Security=False;Pooling=True;Connect Timeout=30;User Instance=False
    Data source connection:
    Data Source=S15564869\SQLSERVERE;Initial Catalog=irismaster;Integrated Security=True



    • Edited by Dan1 Friday, May 18, 2012 10:29 AM
    Thursday, May 17, 2012 9:27 AM

Answers

  • Hi,

    OK I finally found what the problem is in your connection string.

    User connection:
    Data Source=S15564869\SQLEXPRESS;Initial Catalog=BSDmanager;Integrated Security=False;Pooling=True;Connect Timeout=30;User Instance=False

    You're trying to use SQL Server authentication but doesn't specify the username/password. Please add or use Integrated Security=True


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    Wednesday, May 23, 2012 2:22 AM

All replies

  • Hi,

    This may happen when executing below target. 

     <Target Name="DeploySchema" Condition=" '$(RequiresIntrinsicDataSource)' == 'true' and '$(_GenerateSchemaScript)' != 'true' ">
            <DeploySchema ConnectionString="$(PublishConnectionString)" />

            <CreateSqlUser ConnectionString="$(PublishConnectionString)"
                           UserName="$(SqlUserName)"
                           Password="$(SqlUserPassword)"
                           AuthenticationType="$(AuthenticationType)"
                           Condition=" '$(CreateSqlUser)' == 'true' and '$(SqlUserName)' != 'sa' " />
        </Target>

    On my x64 Windows 7 the file has above content is under:

    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v1.0\Microsoft.LightSwitch.targets

    The problem you mentioned may be related to the YourApplication.lsproj.user file. Please open this file in notepad and check whether PublishUserName is empty. Try to delete that file, open Visual Studio and open the project, rebuild and publish to see whether it works. Also check whether this file is readonly or has ACL restrictions.


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    • Edited by Allen Chen - MSFTModerator Tuesday, May 22, 2012 7:02 AM
    • Marked as answer by Dan1 Tuesday, May 22, 2012 5:02 PM
    • Unmarked as answer by Dan1 Tuesday, May 22, 2012 5:43 PM
    Tuesday, May 22, 2012 7:02 AM
  • Hi,

    1) >This may happen when executing below target.

    What do you mean by "below target"?

    2) The file Microsoft.LightSwitch.targets exists and the sequence mentioned by you is present in the file

    3) PublishUserName in lsproj.user  is not empty. The file is not Read-only and I see no other restrictions

    I removed the file then rebuild.  I get the same problem.

    The error message sends to Microsoft.LightSwitch.targets Target Name = "DeploySchema"


    • Edited by Dan1 Tuesday, May 22, 2012 5:55 PM
    Tuesday, May 22, 2012 5:02 PM
  • Hi,

    >What do you mean by "below target"?

    I mean the <Target ..>.

    My mistake that username is NOT got from PublishUserName.. It should be got from <ClientConnectionString>. Could you use below steps and post the final result shown on the Console here?

    1. Create a Console application.
    2. Add reference to c:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\LightSwitch\v1.0\Microsoft.LightSwitch.Build.Tasks.dll
    3. Add reference to C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.Utilities.v4.0.dll
    4. Add reference to C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.Framework.dll
    5. Add testing code (below is my testing one, please replace my innerText with yours, please mask your password in connection string when you post the result on forum for security purpose):
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.LightSwitch.BuildTasks.Deployment;

    namespace ConsoleApplication27
    {
        class Program
        {
            static void Main(string[] args)
            {
                DecryptPassword dp = new DecryptPassword();
                // Copy the innerText of <ClientConnectionString> in the .lsproj.user here. Assign to EncryptedPassword
                dp.EncryptedPassword = "AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAAmrnxx0j3D0OVkVwjUNahigAAAAACAAAAAAADZgAAwAAAABAAAAAQ82JE4MLQnp/QgGWzGSfgAAAAAASAAACgAAAAEAAAAJx/SrGh9LV8b6GoQgTa+bwYAQAA+OgGwXQwy4v1iSx7SG/p8JJcvbDrxYUv3Rj+s3qw3rl1D/7RORu48Zg2WYsZ8f0pDeExFxL09cnX+vt8tUL7vY05UyeqlClhRKny3BgMUKbOra3ig66m5/lsmJeSHSimFE3t+Ysfgwa80vSQYmE00QjRWIwHkQuj8aUapHX5nAOCt17y/BrxpnZo0mZLURjFfKi8r9X5AHRayv2kJ635HCrXUtpCJ+JNJwksJYPoVGmd0lv/z+fMCV/tJj8kPbYR6Jd626WsAaIZPT9gI0SaKjba0mlKaTXtibmTvVta69KlxON3Q+4ze47zgK9Vo1SrCllnfuE/jyGsCrC+vYt3xgxBX16NOecb385RwwpFzLWPqrE5MhyPBhQAAACQq9gth+4r8HcpfsjfgJUnO+JkvQ==";
                dp.Execute();
                GetSqlUserCredentials gsuc = new GetSqlUserCredentials();
                gsuc.ConnectionString = dp.DecryptedPassword;
                gsuc.Execute();
                Console.WriteLine(string.Format("CreateSqlUser:{0}, UserName:{1}",gsuc.ParsedCredentials,
                    gsuc.UserName));
                Console.WriteLine(string.Format("Connection String:{0}", gsuc.ConnectionString));
                Console.ReadLine();
            }
        }
    }

    As the target indicates, the result of your scenario should be CreateSqlUser:true and UserName is empty. The root cause might be something wrong in the connection string.

      <CreateSqlUser ConnectionString="$(PublishConnectionString)"
                           UserName="$(SqlUserName)"
                           Password="$(SqlUserPassword)"
                           AuthenticationType="$(AuthenticationType)"
                           Condition=" '$(CreateSqlUser)' == 'true' and '$(SqlUserName)' != 'sa' " />

    When you find what is wrong in the connection string you can modify the connection string setting in the publish wizard to see whether it works.

    If nothing helps the last resort would be totally remove the CreateSqlUser target from the target file (suggest to back up the original file). Then restart Visual Studio.

    Please let me know the result. Thanks!


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.











    Wednesday, May 23, 2012 1:59 AM
  • Hi,

    OK I finally found what the problem is in your connection string.

    User connection:
    Data Source=S15564869\SQLEXPRESS;Initial Catalog=BSDmanager;Integrated Security=False;Pooling=True;Connect Timeout=30;User Instance=False

    You're trying to use SQL Server authentication but doesn't specify the username/password. Please add or use Integrated Security=True


    Allen Chen [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.



    Wednesday, May 23, 2012 2:22 AM