Publishing lightswitch app via command line does not work

796 views Asked by At

I have been having some issues getting a lightswitch app to publish to a package outside of visual studio.

I think I am probably using the wrong command, but I cant find any information about what commands I should use.

My command looks like this: MSBuild "Path To My Sln.sln" /p:VisualStudioVersion=12.0;DeployOnBuild=true;PublishProfile=Release;Configuration=Release

I get the following error:

    C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web
    .Publishing.targets(3899,5): msdeploy error ERROR_EXCEPTION_WHILE_CREATING_OBJECT: 
    Web deployment task failed. (Object of type 'manifest' and path 
    'manifestpath\projectname.xml' cannot be created.  Learn more at:
    http://go.microsoft.com/fwlink/?LinkId=221672#ERROR_EXCEPTION_WHILE_CREATING_OBJECT.)

The reason for this is that the app.publish folder that is within the manifest file does not exist. The folder should be located in the bin.

When I do a publish via VS the app.publish folder is created, so my current thinking is that VS does something that the command I am running does not, I am not sure what that is though.

The reason for needing this to work via the command line is so that we can create a package on our build server.

2

There are 2 answers

1
Andras Zoltan On BEST ANSWER

In theory, you should be able to target the Publish target of the .lsxtproj root project of the three lightswitch projects. This will trigger a build of all dependencies and then push the Server and HtmlClient project outputs into a package in the Publish\ folder where the .lsxtproj is.

The DeployOnBuild property is exposed by the standard web project targets file to trigger a package creation, but it would seem that this just doesn't apply to LightSwitch projects, which I suppose makes sense given how much Voodootm is doing when it builds. So you'll need to remove that.

If you were creating another project file to act as your build script, then, you'd do something like:

<?xml version="1.0" encoding="utf-8"?>
<Project MSBuildVersion="4.0" ToolsVersion="12.0" DefaultTargets="LSPublish" 
  xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
    <Target Name="LSPublish">
        <MSBuild Projects="[path_to_yourproj].lsxtproj" Targets="Publish" />
    </Target>
</Project>
1
Matt Thalman On

First, you should manually publish your LightSwitch application from within Visual Studio. That will set the appropriate properties in the LightSwitch application project file.

LightSwitch projects do not have publish profiles, so unfortunately you can't make use of those in your scenario. You would need to override any of the properties defined within the LightSwitch project by using the /p switch in MSBuild if you wanted to dynamically set them from the command line.

The next step is that you should call msbuild on the LightSwitch project file rather than the solution. And you need to call the "Publish" target. So this would end up looking like this (project file extension will vary depending on which version of LightSwitch you're using): msbuild MyLightSwitchApp.lsproj /t:Publish /p: