I'm trying to build a .sqlproj referencing master database inside a windows container, but i get this error:
C:\src\Microsoft.Data.Tools.Msbuild.10.0.61804.210\lib\net46\Microsoft.Data.Tools.Schema.SqlTasks.targets(559,5): Build error SQL72027: File
"C:\Extensions\Microsoft\SQLDB\Extensions\SqlServer\130\SqlSchemas\master.dacpac"
does not exist.
I read many threads about the problem, and from my understanding master.dacpac is only installed during Visual Studio installation phase. However inside the container I do not want to install VS.
If I copy the master.dacpac from my VS host installation path into the container, the project builds successfully.
My question is:
is there a cleaner way to build a .sqlproj from msbuild when it is referencing master.dacpac?
My current solution requires a pre-build script copying master.dacpac from visual studio installation folder to Dockerfile folder, and seems to me the wrong way to go.
At the moment my Dockerfile is like this (pseudo code)
FROM microsoft/dotnet-framework:4.7.2-sdk-windowsservercore-ltsc2019 AS builder
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
WORKDIR C:\src
RUN nuget.exe install Microsoft.Data.Tools.Msbuild
# copy master.dacpac into the container + manually deploy it for msbuild
RUN mkdir C:\Extensions\Microsoft\SQLDB\Extensions\SqlServer\130\SqlSchemas
COPY master.dacpac C:\Extensions\Microsoft\SQLDB\Extensions\SqlServer\130\SqlSchemas\master.dacpac
# copy sqlproj source code into the container
COPY ${SQLPROJ_SRC_ROOT_DIR} .
RUN msbuild ${SQLPROJ_NAME_WITHOUTEXT}.sqlproj `
/p:SQLDBExtensionsRefPath="C:\src\Microsoft.Data.Tools.Msbuild.10.0.61804.210\lib\net46" `
/p:SqlServerRedistPath="C:\src\Microsoft.Data.Tools.Msbuild.10.0.61804.210\lib\net46"
Related
RAD Studio 2010 project build using MSBuild works fine when I build it locally. Subprojects that build BPL files end up under C:\Users\Public\Documents\RAD Studio\7.0 like it's supposed to since no other output directory is set.
When building using TeamCity it all fell apart. Complaining it could not find BPL files generated by subprojects. Looking in the directory where it should end up nothing was created there. Instead, the BPL files ended up in the projects directory.
After scratching my head, checking environment variables etc and all the BDSCOMMONDIR and similar variables are set etc it dawned on me that the TeamCity build Agent was running as the SYSTEM account. I opened a command prompt as the SYSTEM account using
PsExec.exe -i -s cmd.exe
I checked environment variables again, they all existed for the account. Started a build locally as SYSTEM and the same issue. BPL files in the project directory instead of the default folder, subsequent projects not finding the BPL files since they look in the default location, build failed.
But why?
Using another user it compiles fine and running the TeamCity build agent as that user enables TeamCity to finish the build correctly to.
I am trying to use TeamCity to automate the publish of my database project after it builds.
I am using the MSBuild runner with "Publish" targets
My SQL project contains a publish profile file "Test.publish.xml"
I used this MSBuild parameter to tell MSBuild which publish profile file to use:
/p:SqlPublishProfilePath=Test.publish.xml
The output path of the project has been modified, so instead of the default "bin\Output" it is "sql\Staging"
When the build step executes I get the error:
[12:19:11]Step 3/3: Publish (MSBuild) (5s)
[12:19:15][Step 3/3] Alpha\Alpha.sqlproj.teamcity: Build target: Publish
[12:19:15][Alpha\Alpha.sqlproj.teamcity] SqlPublish
[12:19:15][SqlPublish] SqlPublishTask
[12:19:15][SqlPublishTask] C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\SSDT\Microsoft.Data.Tools.Schema.SqlTasks.targets(1717, 5): File "D:\BuildAgent\work\8c364da49a1f90ba\Alpha\bin\Output\Alpha.sqlproj.dacpac" does not exist.
[12:19:16][Step 3/3] Step Publish (MSBuild) failed
So, as you can see, it is looking for the .dacpac file in the standard bin\Output directory instead of the modified output directory path.
Also, it is expecting the dacpac file to be called Alpha.sqlproj.dacpac, but my dacpac file is called Alpha.dacpac
What I need to do somehow is tell MSBuild where to find the dacpac file, because it is not taking any notice of the custom build output directory. Is there another MSBuild parameter or something that I can add to my publish profile file?
I know I could use sqlpackage.exe as an easy alternative, but it does not seem to be on the machine (at C:\Program Files\Microsoft SQL Server\110\DAC\bin), despite SQL Server Data Tools being installed and that is another battle I am working on...
I'm developing an ASP.NET Core 1.0 application which I deploy to a Linux machine using Docker.
In my CI pipeline I'm publishing the project using dnu publish, then I build the docker image with docker build.
I have a static binary file that I need to use in my docker image. (It's a hotfix which I need to copy into the coreclr runtime directory.) I want to be able to access that file with a command from my Dockerfile.
What is the idiomatic, reliable way to make that file get copied into the output directory when I'm doing dnu publish? What I'm currently doing - because I couldn't find a better solution - is adding it to wwwroot, so it gets copied into wwwroot in the output folder.
However, I don't want that file to be publicly accessible, it would be much better to make it end up in approot.
The approaches I found on SO and tried, but are not working:
Including the file in the project.json as "contentFiles": [ "mylib.so" ]. If I do this, I get the following error during the dnx build:
Error: The process cannot access the file 'C:\myapp\src\myapp.web\mylib.so' because it is being used by another process.
I tried to experiment with creating a custom postBuild script (found the suggestion here: New .NET "project.json" project, copying pre-built native .dlls to the output directory), but I can't figure out where to copy the file, since I have different CI pipelines publishing the same project using different publish output directories, so I cannot hardcode the directory path into my project.json.
Or is there a way to copy it into the build directory, which will be picked up by dnu publish regardless of the output directory of publish?
I am newbie to TFS.
I am trying to automate process of build upon checking in the code in TFS.
I setup a Controller and an Agent. I created a new build definition and set a "build" and "drop" folder on c:.
I check in the code, expecting to see the generated dll files in "drop" folders. There's none, just "logs" folder. The "binaries" folder in "build" folder is also empty. Apparently the binaries are not being generated at all. How can I have MSBuild to generate the dll files?
They are generated when I compile the website locally on my development machine under "bin\" folder. The solution is comprised of two separate projects: "core" and "web" where "core" is referenced within "web".
Any thoughts?
What is the Summary showing of your build that ran? Or are there errors in your build? You can check the log of the build by opening the build in Visual Studio and then click View Log.
I'm trying to get a Lightswitch Project into Teamcity and have tried the following runner types:
Visual Studio (sln)
MSBuild
Command line (ran MSBuild through the command line)
All 3 runner types gave me the same error when building the Lightswitch solution:
The "UnpackExtensionsToProjectDir" task failed unexpectedly. System.NullReferenceException: Object reference not set to an instance of an object.
Lightswitch has already been installed on the server. Have tried building the solution manually using Visual Studio on the server and it builds fine. Have also tried building the solution via the command line (using MSBuild) and it builds fine too.
Would like to ask if somebody was able to get Lightswitch building nicely on TeamCity. Cheers.
This is how you build via the Command line (using TeamCity)
Pre-requisites)
First make sure you have not checked in the extensions directory, this can cause issues when building.
Check that you have installed any visual studio extensions on the build machine .ie ExtensionsMadeEasy. You can test this by opening the solution in visual studio on the build machine and trying to do a build.
Lastly, in TeamCity do not use the msbuild task, use command line to call msbuild.
Step 1)
msbuild.exe mylightswitchproject.lsproj /p:OutDir=C:\test\stuff\;configuration=Release
Step 2)
Create a bat file to copy your output to the correct folder structure.
robocopy C:\test\stuff\bin C:\test\localrelease\bin *.* /MIR
robocopy C:\test\stuff\Resources C:\test\localrelease\Resources *.* /MIR
robocopy C:\test\stuff\Web C:\test\localrelease\Web *.* /MIR
robocopy C:\test\stuff\ C:\test\localrelease\ ClientAccessPolicy.xml
robocopy C:\test\stuff\ C:\test\localrelease\ default.htm
robocopy C:\test\stuff\ C:\test\localrelease\ Home.aspx
robocopy C:\test\stuff\ C:\test\localrelease\ Login.aspx
robocopy C:\test\stuff\ C:\test\localrelease\ LogOff.aspx
robocopy C:\test\stuff\ C:\test\localrelease\ Silverlight.js
robocopy C:\test\stuff\ C:\test\localrelease\ web.config
You can now take this folder and release it to the next environment.
Finally, if you want to create a web deployment package, out the box visual studio 2010 does not support this. However, you can copy this into an existing website then "Export" your application into a package that is then ready for web deployment via powershell.
The previous answers didn't work for us but Yaegor's answer provided some direction.
The issue we had was extensions are installed at the user level, not the system level. This meant the MSBuild process could not find the required extensions.
Our solution was to use a user account on the build server, log into account, setup VS.NET such that the LS project builds, and then switch the TeamCity agent service to use the new user account.
With this we were able to use the Solution runner (which is preferable to the CLI runner since it provides better logging and reporting).
For not Lightswitch-specific part: If command line works from console, but fails in TeamCity, most probably the issue is in the user or running as a service. You might try running TeamCity agent with the same environment.
When command line works you can then try MSBuild and Solution runners.
I ran into the same error when trying to set up an automated build for a lightswitch application using bamboo. Turned out to be the version of msbuild being called. If the 64bit version is called (from bamboo or the command line) I get the error:
UnpackExtensionsToProjectDir" task failed unexpectedly.
Switching to the 32bit version of msbuild fixes the problem.
32bit Path: 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe'
64bit Path: 'C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe'