Closed drdr-kr closed 1 month ago
I've dug a bit deeper, and figured out that I can execute sqlpackage via powershell doing something like this:
var sqlpackage = builder.AddExecutable("sqlpackage", "powershell", ".", $"{Environment.CurrentDirectory}\\sqlpackage.ps1")
.WithReference(addressBookDb)
.WaitFor(sqldb)
;
and then in the sqlpackage.ps1
script file I have the following
./sqlpackage.exe /Action:Publish /SourceFile:./sqlsetup/My.dacpac /TargetConnectionString:$env:ConnectionStrings__AddressBook
So, I think this is resolved using a workaround, it would be nice if this could be done a bit more neatly but thanks for all the work you're doing on Aspire :-)
You could also have a look at: https://www.nuget.org/packages/MSBuild.Sdk.SqlProj.Aspire
Is there an existing issue for this?
Describe the bug
I have a minimalist Aspire app up and running, which has SQL Server added using the Aspire hosting package
I'm trying to launch sqlpackage as an executable during startup to bring the database up to the expected state like so
however, despite trying a few different formats I can't get sqlpackage to recognise the connection string. I think it's probably because the value is escaped when running it's not able to recognise the environment variable. I've tried
"/TargetConnectionString:\"%ConnectionStringsAddressBook%\"" "/TargetConnectionString:\"$ConnectionStringsAddressBook\"" "/TargetConnectionString:\"$ConnectionStrings__AddressBook$\""
Expected Behavior
No response
Steps To Reproduce
No response
Exceptions (if any)
No response
.NET Version info
No response
Anything else?
No response