VS2010 DB Project Deploy Error SQL01268 Directory Lookup Failed - visual-studio-2010

My VS2010 database deploy is failing on my build server, which has SQL Server 2008 R2 installed on it. Here's the output that's relevant:
Creating Acme.Database...
D:\TeamCity\BuildAgent\Work\da2fc5ebd5805d44\src\Acme.Database\sql\Acme.Database.sql(30,0): Error SQL01268: .Net SqlClient Data Provider: Msg 5133, Level 16, State 1, Line 1 Directory lookup for the file "C:\Program Files\Microsoft SQL Server**MSSQL10.MSSQLSERVER**\MSSQL\DATA\Acme_Database_log.ldf" failed with the operating system error 3(The system cannot find the path specified.).
D:\TeamCity\BuildAgent\Work\da2fc5ebd5805d44\src\Acme.Database\sql\Acme.Database.sql(30,0): Error SQL01268: .Net SqlClient Data Provider: Msg 1802, Level 16, State 1, Line 1 CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
An error occurred while the batch was being executed.
The actual path is here:
C:\Program Files\Microsoft SQL Server**MSSQL10_50.MSSQLSERVER**\MSSQL\DATA\Acme_Database.mdf
The only reference to the path I could find in the database project was in the root folder, a file called:
PRIMARY.Acme_Database.sqlfile.sql
It includes an ALTER DATABASE statement that I changed to use the _50 path, but this did not fix the issue.
I'm not sure why the db project needs to know where the actual database MDF file is located in any case - I would have thought it could just connect to it vis TSQL, but in any case I can't get the project to deploy with this error and would appreciate any help.

Turns out if you specify a "file" in Schema Objects\Database Level Objects\Storage\Files (use Add Item, File) the values specified in the path override those looked up from the Server. If you must specify them use the variables from sqlcmdvariables $(DefaultdataPath)$(Databasename) to fill things out.

Take a look at the default file path on the server itself.
Screencast: http://screencast.com/t/OWM5ODFjZj
The fact that you don't have a path specified could likely be the issue.
[Update]
The reason I suggest this is that during the creation of the deployment script, if you have not specified the settings in the Project Settings -> Deployment tab, the DefaultDataPath is looked up from the target server's path.

I don't know anything about TeamCity really so this may be a stupid question, but how are you doing the deployment? It looks like the MSBuild deploy task for a DB project can take a property that gives the data path:
http://www.codewrecks.com/blog/index.php/2009/10/06/deploy-a-database-project-with-tfs-build/
Can you set the path that way?

I had the same error, but a different solution.
For me everything was correct (as far as I can tell), but the generated deploy script set the path variables before the databasename variable - resulting in a reference to a variable that did not exist. I updated Database.sqlcmdvars to hardcode the database name value - not best practice, but a sufficient workaround for my needs.

Related

How to pass SQLCMD variables du MSBuild during Build?

I am referencing a database project during publish in a second database project. For easier reference, let's call them Database and Database.Tests.
Database is being referenced by Database.Tests
During deployment the Database project will be deployed twice to the same machine. Once as "Database" and once as part of "Database.Tests"
Doing this manually using the publish option is working as expected, however when using SqlPackage.exe I am running into an error when publishing the seoncd database:
*** Could not deploy package.
Error SQL72014: .Net SqlClient Data Provider: Msg 33415, Level 16, State 4, Line 5 FILESTREAM DIRECTORY_NAME 'AZE' attempting to be set on database 'Database.Tests' is not unique in this SQL Server instance. Provide a unique value for the database option FILESTREAM DIRECTORY_NAME to enable non-transacted access.
Error SQL72045: Script execution error. The executed script:
IF EXISTS (SELECT 1
FROM [master].[dbo].[sysdatabases]
WHERE [name] = N'$(DatabaseName)')
BEGIN
ALTER DATABASE [$(DatabaseName)]
SET FILESTREAM(NON_TRANSACTED_ACCESS = FULL, DIRECTORY_NAME = N'AZE'),
CONTAINMENT = NONE
WITH ROLLBACK IMMEDIATE;
END
Here is what I am doing. the first thing is to create the test database. To do that I am deploying tSQLt, the Database project and lastly the database.tests project using the following sqlPackage.exe commands:
"C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Publish ^
/SourceFile:"Database.dacpac" ^
/TargetDatabaseName:"Database.Tests" ^
/TargetServerName:"server\instance" ^
/v:MSSQL_USER="some_user" ^
/v:MSSQL_PASSWORD="somepassword"
"C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Publish ^
/SourceFile:"Database.dacpac" ^
/TargetDatabaseName:"Database.Tests" ^
/TargetServerName:"server\instance"
"C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Publish ^
/SourceFile:"Database.Tests.dacpac" ^
/TargetDatabaseName:"Database.Tests" ^
/TargetServerName:"server\instance"
# at this point we deploy the second database into a database called `Database`
"C:\Program Files\Microsoft SQL Server\150\DAC\bin\SqlPackage.exe" /Action:Publish ^
/SourceFile:"Database.dacpac" ^
/TargetDatabaseName:"Database" ^
/TargetServerName:"server\instance" ^
/v:MSSQL_USER="some_user" ^
/v:MSSQL_PASSWORD="somepassword"
Can I dynamically change the filestream directory setting at deployment-time or circumvent this issue in some other way? In theory I only need the schema, sprocs and functions from the Database project in my test database to execute my tSQLt tests and nothing else.
This may not answer your question directly, but here goes.
We make extensive use of SSDT and tSQLt. In our database solutions, the unit tests reside in their own project. (Using composite projects the root project is everything common to all environments; dev, stage, prod and unit test are separate projects in the solution.) The dev project has a database reference to the unit test project. The reference is marked as same database. That way when dev deploys it carries the unit test project items with it. And the unit test project would not need the FILESTREAM settings.
FILESTREAM settings would be relative to each environment project and would not be in the unit test project. That way only a single reference is ever deployed.
If you only have the root project and a unit test project in the solution you could still accomplish it with a database reference as noted above. Either way, the unit test project is never deployed directly, only by reference from another project in the solution.

Build InstallShield project outside of Visual Studio

I have created a solution using Visual Studio 2017 which consists of a Windows Service C# Project and an InstallShield 2016 Basic MSI Project.
The InstallShield project has a single component added. This component has a number of files added using the Component->Files->Add File... (below)
Note the use of VSSolutionFolder.
Now when I open the InstallShield project (.ism) using InstallShield 2016, and build the project, I get the following build errors:
Loading File table
ISDEV : error -6103: Could not find file "<VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\ACMECorp.App.Service.exe"
ISDEV : error -6103: Could not find file "<VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\ACMECorp.App.Service.exe.config"
ISDEV : error -6103: Could not find file "<VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\ACMECorp.App.Service.pdb"
ISDEV : error -6103: Could not find file "<VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\App.config"
Building MsiFileHash table
ISDEV : error -6271: File <VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\ACMECorp.App.Service.exe not found. An error occurred building the MsiFileHash table record for this file. Verify that the file exists in the specified location.
ISDEV : error -6271: File <VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\ACMECorp.App.Service.exe.config not found. An error occurred building the MsiFileHash table record for this file. Verify that the file exists in the specified location.
ISDEV : error -6271: File <VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\ACMECorp.App.Service.pdb not found. An error occurred building the MsiFileHash table record for this file. Verify that the file exists in the specified location.
ISDEV : error -6271: File <VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\App.config not found. An error occurred building the MsiFileHash table record for this file. Verify that the file exists in the specified location.
Adding instance transforms to substorage...
ISDEV : error -1007: Cannot copy source '<VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\ACMECorp.App.Service.exe' to target 'E:\Installshield\WebDeploy\Windows Services\ACMECorp.App.Service\ACMECorpSetup\ACMECorpSetup\Default Configuration\Release\DiskImages\DISK1\program files\ACME Corp\ACME Corp Service 0\ACMECorp.App.Service.exe'
ISDEV : error -1007: Cannot copy source '<VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\ACMECorp.App.Service.exe.config' to target 'E:\Installshield\WebDeploy\Windows Services\ACMECorp.App.Service\ACMECorpSetup\ACMECorpSetup\Default Configuration\Release\DiskImages\DISK1\program files\ACME Corp\ACME Corp Service 0\ACMECorp.App.Service.exe.config'
ISDEV : error -1007: Cannot copy source '<VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\ACMECorp.App.Service.pdb' to target 'E:\Installshield\WebDeploy\Windows Services\ACMECorp.App.Service\ACMECorpSetup\ACMECorpSetup\Default Configuration\Release\DiskImages\DISK1\program files\ACME Corp\ACME Corp Service 0\ACMECorp.App.Service.pdb'
ISDEV : error -1007: Cannot copy source '<VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\App.config' to target 'E:\Installshield\WebDeploy\Windows Services\ACMECorp.App.Service\ACMECorpSetup\ACMECorpSetup\Default Configuration\Release\DiskImages\DISK1\program files\ACME Corp\ACME Corp Service 0\App.config'
In Media Path Variables, there is a VSSolutionFolder with a value UNDEFINED.
I cannot change this Current Value - the UI does not allow it. Defined Value cannot be changed and Test Value doesn't seem to do much.
I have the project saved as xml but I only see the VSSolutionFolder referenced in file paths like so:
<row>
<td>acmecorp.app.service.exe</td>
<td>ACMECorpServiceFilesComponent</td>
<td>ACMECO~1.EXE|ACMECorp.App.Service.exe</td>
<td>0</td>
<td/>
<td/>
<td/>
<td>1</td>
<td><VSSolutionFolder>\ACMECorp.App.Service\bin\Debug\ACMECorp.App.Service.exe</td>
<td>1</td>
<td/>
</row>
Is there a way of setting VSSolutionFolder in InstallShield? Or is there some way of fixing this.
Ideally I want it to just load in Visual Studio and InstallShield without having to muck about with source locations - yes I can remove the files and re-add, but that is not the question (if I had a larger solution it wouldn't be acceptable I don't think).
Personally I recommend keeping your application code and your installer code in two different solutions. There are several reasons including:
1) A new version of VS comes out that IS doesn't support yet and you don't want to be held back.
2) Simplifies project dependencies and build order relationships. Build your app code first then build your installer code second.
3) Depending on where you are in the agile/devops spectrum you might want to keep your peanut butter and chocolate separate.
In this scenario I use postbuild xcopy commands and msbuild publish profiles to stage my application code to a "Deploy" directory in the workspace in the directory that your .ISPROJ and .ISM lives. From there InstallShield simply uses the standard ISPROJECTDIR path variable reference. Now you don't have to deal with the complexities of project output references. You have a nice model defined of what your deployed application should look like.
Try overriding the path variable. You can do this either with external approaches like iscmdbld -L... or with the Release Configuration property Path Variable Overrides. (Note that building the solution with MSBuild should already just work.)
If there are problems overriding VSSolutionFolder itself, you can change your file links to use a new standard variable that is defined to use <VSSolutionFolder> as its default path, but will definitely allow you to override it.

File Replace during upgrade

We use Inno Setup(version 5.4.2) as the packaging tool to generate our installer. While upgrading our software from older version to current version,
we try to overwrite existing binaries/drivers. This is often leading to issues as some monitoring software like 'HP ArcSight Logger/Connector', 'SplunkUniversalForwarder' etc. are holding file handles on our binaries and casuing overwrite to fail. Our installer shows beolow popup message on encountering this issue each time.
"C:\Windows\System32\drivers\xxx.sys
An error occurred while trying to replace the existing file:
DeleteFile failed; code 5.
Access is denied.
Click Retry to try again, Ignore to skip this file(not recommended), or Abort to cancel installation"
Interestingly, even after above getting above pop-up, we were able to rename xxx.sys to xxx.sys.old manully. We used to suggest cusotmers to rename
xxx.sys to xxx.sys.old and 'Retry' the installation. After renaming, upgrade used to complete without any issues.
Questions
1) Is it possible to rename xxx.sys through program always, when we hit this issue.
2) Any process to reproduce the DeleteFile failed; code 5 issue?
Using the installer you can rename the existing file and install the new file using the correct file name with help from the windows registry.Remember to ask the user to reboot their computer to complete the install.Another option would be to either use the installer to rename the file and again using the window's registry to delete the unneeded file.
Window's registry allows you to delete or rename files on reboot as part of an install.
Reference to use of PendingFileRenameOperations:
http://support.microsoft.com/kb/181345
Example to rename from microsoft support:
The syntax used is (without quotes):
"\??\source file !\??\target file"
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
Value name: PendingFileRenameOperations Data type : REG_MULTI_SZ
Value data: \??\c:\temp\win32k.sys !\??\c:\winnt\system32\win32k.s
The same command can be used to delete a file as well although requires the use of nulls.
http://www.pcreview.co.uk/forums/pendingfilerenameoperations-delete-file-t1715654.html
Same example used to delete a file:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
Value name: PendingFileRenameOperations Data type : REG_MULTI_SZ
Value data: \??\c:\temp\win32k.sys\0\0\0
I hope this helps you!

CREATE DATABASE fails using VSDBCMD

When trying to deploy a VS2010 database project using the VSDBCMD tool, I get the following error:
SQL01268 .Net SqlClient Data Provider: Msg 5133, Level 16, State 1, Line 1 Directory lookup for the file "D:\MSSQL10_50\MSSQL10_50.MSSQLSERVER\MSSQL\Data\Data.mdf" failed with the operating system error 21(failed to retrieve text for this error. Reason: 1815).
SQL01268 .Net SqlClient Data Provider: Msg 1802, Level 16, State 1, Line 1 CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
However, if I take the SQL script generated by VSDBCMD and run it in SQL Management Studio, it works fine. Similarly, I can create the DB manually in Mgt Studio.
'Operating system error 21' is apparently Device Not Ready, but this looks spurious to me... The folder paths are all correct, and unlocking the security on the folders doesn't fix the issue (e.g. 'everyone' > full control). Also, there are no errors in the SQL log or event viewer on the server.
What is different between running VSDBCMD on the command line, and running the same SQL script through Management Studio??
Any ideas very welcome!
Chris
As per my own comments, this error was because the drive didn't actually exist.
If you are creating database with vsdbcmd in a server based on a dbschema, it would be nice to set path location for data and log files.
To change log path location in your .dbschema file:
<Element Type="ISql90File" Name="[YOUR_DATABASE_NAME_Data]">
<Property Name="FileName" Value="E:\YOUR DATA FOLDER\$(DatabaseName)_Data.MDF" />
<Element Type="ISql90File" Name="[YOUR_DATABASE_NAME_Log]">
<Property Name="FileName" Value="E:\YOUR LOGS FOLDER\$(DatabaseName)_Log.LDF" />
then import it into Sql Server using Command prompt:
CD\
"C:\Program Files (x86)\Microsoft Visual Studio 10.0\VSTSDB\Deploy\vsdbcmd.exe" /a:Deploy
/cs:"Server=YOUR_SERVER\YOUR_INSTANCE;User Id=YOUR_USER;Password=YOUR_PASS;Pooling=false"
/dsp:Sql /dd+ /model:"C:\FOLDER\YOUR_DBSCHEMA_FILE.dbschema"
/p:TargetDatabase="YOUR_DATABASE_NAME"
More info on vsdbcmd: http://msdn.microsoft.com/en-us/library/dd193283.aspx

SQR 5543 error. Report arguments in sqrw

I am trying to run SQRW and it asks for report arguments.
I entered -ZIF"path to my pssqr.ini" (without the quotes)
once I hit OK I get the error (SQR 5543) Specify the Oracle DLL name in the SQR.INI file in [Environment:Oracle] section for ORACE_DLL entry, such as
ORACLE_DLL=orant71.dll
I tried to add the oracle dll bin path to my search path and I also tried added that ORACLE_DLL= to the pssqr.ini file. Neither worked but i'm not even sure which dll file I should get. There is nothing like orant71.dll in my oracle bin directory.
Which dll file do I use if i have oracle 11?
Are there any other suggestion of what I can do or what is wrong?
In case anyone else runs into this problem, I fixed it by installing Oracle 10g rather than 11g. This fixed it, I don't know why though.

Resources