CREATE DATABASE fails using VSDBCMD - visual-studio-2010

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

Related

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.

How to overcome "Could not load type 'Microsoft.Cct.Services.Sqm.IWatSqmService'" without updating?

I'm getting the same error message as in this question: Could not load type 'Microsoft.Cct.Services.Sqm.IWatSqmService' Unfortunately, I cannot upgrade to Azure SDK 2.9, as the top answer there suggests.
Specifically, I get this error in a message box whenever I try to package my Azure Cloud Service project:
What's interesting is that I can start the same project in the emulator, which I would assume involves packaging it.
Things I've tried:
Ensuring that I only have version 2.8.2 of the emulator installed (I may have had 2.9 installed initially)
Reinstalling version 2.8.2 of the SDK
Manually copying the Windows Azure Tools from C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v10.0 to the v14.0 equivalent.
Ensuring that C:\Program Files\Microsoft SDKs\Azure\.NET SDK\v2.8 exists
Reinstalling Visual Studio (so you know I'm desperate!)
And I've no idea what to try next. I can't work out which DLL is supposed to hold the Microsoft.VisualStudio.WindowsAzure.Services assembly, I can't find any references in any config files, and all the Google hits seem to point back to the SO question linked above.
What's going on? And how can I fix it?
In case I'm being an idiot, here's all the Azure-related things I've got installed:
Also (just in case it's relevant) I'm on Windows 7 SP1.
Update 17/01/16
Following some advice from the excellent Rest Azured Slack channel, I've tried using ProcMon and Fusion Log to diagnose this (spoiler: without success)
ProcMon filtered to that assembly returns nothing:
Fusion log (set to log everything) yields lots of entries like this:
* Assembly Binder Log Entry (17/01/2017 # 11:52:02) *
The operation was successful. Bind result: hr = 0x0. The operation
completed successfully.
Assembly manager loaded from:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\clr.dll Running under
executable C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\devenv.exe
--- A detailed error log follows.
=== Pre-bind state information === LOG: DisplayName = Microsoft.VisualStudio.WindowsAzure.Services, Version=1.1.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a (Fully-specified)
LOG: Appbase = file:///C:/Program Files (x86)/Microsoft Visual Studio
14.0/Common7/IDE/ LOG: Initial PrivatePath = NULL LOG: Dynamic Base = NULL LOG: Cache Base = NULL LOG: AppName = devenv.exe Calling assembly
: Microsoft.VisualStudio.WindowsAzure, Version=2.9.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
=== WRN: Native image will not be probed in LoadFrom context. Native image will only be probed in default load context, like with
Assembly.Load(). WRN: No matching native image found. LOG: IL assembly
loaded from C:\Program Files (x86)\Microsoft Visual Studio
14.0\Common7\IDE\Extensions\Microsoft\Windows Azure Tools\Microsoft.VisualStudio.WindowsAzure.Services.dll.
When I explore the DLL mentioned, I can find Microsoft.Cct.Services.Sqm, but it doesn't contain a type IWatSqlService:
This feels like it's the crux of the issue, but I've no idea what to do next. Presumably I'd need to replace the DLL with a version that does define IWatSqlService, but I'm not sure where I'd get one. Or, for that matter, why it would even be necessary.
Next stop is probably a full wipe of the machine.
I've had the same problem, and solved it by not using the Web Platform Installer.
Download all parts (Microsoft Azure SDK for .NET - 2.8.2) from the Microsoft site: https://www.microsoft.com/en-us/download/details.aspx?id=50041 and follow the instructions how to install them.
For anyone else with this problem. I ended up resolving this by nuking it from orbit. Fresh install of Windows, reinstall VS and the SDK.
Confusingly, you can also see this error when you add a new
<setting name="TODO" />
element to your *.csdef file but either:
forget to add the corresponding <setting name="TODO" value="TODO" /> element to every *.cscfg file, or
accidentally add a duplicate <setting name="TODO" value="TODO" /> element to any of the *.cscfg files.

DataDriven Unit Test using Excel in VS2013

I am creating Datadriven Unit(MS Unit Test) Test using Excel(*.xlsx) file as data source.
it is erroring out with the following error
Result Message: The unit test adapter failed to connect to the data
source or to read the data. For more information on troubleshooting
this error, see "Troubleshooting Data-Driven Unit Tests"
(http://go.microsoft.com/fwlink/?LinkId=62412) in the MSDN Library.
Error details: ERROR [IM014] [Microsoft][ODBC Driver Manager] The
specified DSN contains an architecture mismatch between the Driver and
Application
I have set the Copy to Output directory : always for the DateRangeTest.xlsx
I also tried defaultdir=.\;, defaultdir=.;, and defaultdir=c:\projectName\bin\debug\;
Here is the section from app.config
<configSections>
<section
name="microsoft.visualstudio.testtools"
type="Microsoft.VisualStudio.TestTools.UnitTesting.TestConfigurationSection, Microsoft.VisualStudio.QualityTools.UnitTestFramework, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
/>
</configSections>
<connectionStrings>
<add name="DateRangeConstr"
connectionString="Dsn=Excel Files;dbq=DateRangeTest.xlsx;defaultdir=.\; driverid=790;maxbuffersize=2048;pagetimeout=5"
providerName="System.Data.Odbc" />
</connectionStrings>
<microsoft.visualstudio.testtools>
<dataSources>
<add name="DateRangeTestDataSource"
connectionString="DateRangeConstr"
dataTableName="Sheet1$"
dataAccessMethod="Sequential"/>
</dataSources>
</microsoft.visualstudio.testtools>
There are (2) options here - you can either remove the DSN requirement or install the opposite Excel/Access runtime bitness of the Office product you have installed.
Option 1 - remove DSN from Connection String
Change from this:
<add name="DateRangeConstr"
connectionString="Dsn=Excel Files;dbq=DateRangeTest.xlsx;defaultdir=.\; driverid=790;maxbuffersize=2048;pagetimeout=5"
providerName="System.Data.Odbc" />
To this:
<add name="DateRangeConstr"
connectionString="dbq=DateRangeTest.xlsx;defaultdir=.\; driverid=790;maxbuffersize=2048;pagetimeout=5"
providerName="System.Data.Odbc" />
Option 2 - Install ODBC Drivers for Opposite Bitness
For Office x64, install Microsoft Access Database Engine 2010 Redistributable for x86 (AccessDatabaseEngine.exe)
For Office x64, install Microsoft Access Database Engine 2010 Redistributable for x64 (AccessDatabaseEngine_x64.exe).
This fix should be the same whether you have Office 2010 or Office 2013.
To test this change - you should be able to configure the Excel Files DSN for both x86 and x64 once installed.
32-bit ODBC: %WINDIR%\SysWOW64\odbcad32.exe
64-bit ODBC: %WINDIR%\System32\odbcad32.exe
Click on "Excel Files" and then click "Configure" and you should see a dialog. If an error occurs when you click "Configure" - you don't have the proper office driver installed for that bitness.
We need not to install anything to our system to run the external excel data driven unit tests.
We need to simply run the Data Source Wizard present under Visual Studio Data Source Explorer.
Watch this video. This Tutorial tells how to run Data Driven (Parameters) unit tests using Visual Studio Testing Tools.

SSRS does not recognize custom DLL

I'm developing SSRS reports via VS2010 on my local machine.
I need to reference from a certain report to a DLL I wrote, The DLL was built at .net framwork 3.5 and I've placed the dll in the following libraries:
1.C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\PrivateAssemblies.
2.C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin
both on my local machine and the server where SSRS is located.
I've also added rssrvpolicy.config file as following:
<CodeGroup
class="UnionCodeGroup"
version="1"
PermissionSetName="FullTrust"
Name="Test"
Description="">
<IMembershipCondition
class="UrlMembershipCondition"
version="1"
Url="C:\Program Files\Microsoft SQL Server\MSRS10_50.MSSQLSERVER\Reporting Services\ReportServer\bin\Test.dll"
/>
Done all that' I've referenced the DLL through the report properties but yet recieved the following error message while previewing the report:
"An error occured during local report processing, The definition of the report X is invalid.
Error while loading code module "Test ...' Could not load file or assembly 'Test ...' or one of its dependenies. The system cannot find the file specified"
Any ideas?
OK found the problem!
Apperntly installing VS2010 on win7 64 bit create two Microsoft Visual Studio 10.0 folders, one in Program Files where I've located my DLL and one in Program Files (x86) where I should have located it.
Once the DLL was put in the correct folder the report recognized it.
Thanks for your reply

VS2010 DB Project Deploy Error SQL01268 Directory Lookup Failed

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.

Resources