locked
MSBuild / file format for .jsproj

    Question

  • In our endeavour to have a clean and reliable code base right from the start, we want to setup some build mechanism and unit testing to be run by a CI server.

    The first question on this subject is: it used to be possible to call MSBuild from command line to build a package, but while there are lots of MSBuild-related files - and functionality, from within Visual Studio -, I couldn't find any way to call it from the command line at the moment. Do you know, when this feature will be available again?

    Now I have read up a bit on the MSBuild file format specification and looked at a .vcxproj file compared to a .jsproj file. The former allows to include or exclude various files depending on the active build configuration using

    <ExcludedFromBuild Condition="'$(Configuration)'=='Release'">true</ExcludedFromBuild>

    But in the .jsproj this doesn't seem possible. In the VisualStudio IDE, this makes the whole header row in the file properties dialog quite superfluous because it effectively doesn't do anything, so I'm guessing this is still pending implementation?

    Also, I cannot find Microsoft.Build.xsd. Where does it reside and do you even think it would help me to understand the .jsproj file format regarding the issue at hand?

    All the best

    Marcus

    Wednesday, February 29, 2012 3:01 PM

Answers

  • Regarding the ExcludedFromBuild question: it is in fact not supported in WinJS projects. A workaround is the following:
    <
    Content Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" Include="css\test.css" />   
    <
    None Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" Include="css\test.css" />

    • Marked as answer by Marcus Ilgner Friday, March 02, 2012 8:34 AM
    Thursday, March 01, 2012 9:51 PM

All replies

  • >> The first question on this subject is: it used to be possible to call MSBuild from command line to build a package, but while there are lots of MSBuild-related files - and functionality, from within Visual Studio -, I couldn't find any way to call it from the command line at the moment.

    Do you mean creating a package to upload to the Windows Store? You can do this by simply building your EXE project on the command line. After build, when you look at the project directory you will find an \AppPackages folder consisting of your packages.

    >> In the VisualStudio IDE, this makes the whole header row in the file properties dialog quite superfluous because it effectively doesn't do anything, so I'm guessing this is still pending implementation?

    Could you share your modified .jsproj file?

    >> Also, I cannot find Microsoft.Build.xsd. Where does it reside and do you even think it would help me to understand the .jsproj file format regarding the issue at hand?

    You can find it here on disk: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.xsd. I don't think it will necessarily help you understand the .jsproj file format. The .jsproj file format uses the same schema and properties and such as any other MSBuild project. The best way is to use MSDN docs to understand MSBuild and understanding the .jsproj file will just follow.

    Wednesday, February 29, 2012 7:09 PM
  • >>>> The first question on this subject is: it used to be possible to call MSBuild from command line to build a package, but while there are lots of MSBuild-related files - and functionality, from within Visual Studio -, I couldn't find any way to call it from the command line at the moment.

    Edit: This is working now!
    >>Do you mean creating a package to upload to the Windows Store? You can do this by simply building your EXE project on the command line. After build, when you look at the project directory you will find an \AppPackages folder consisting of your packages.

    >>>> In the VisualStudio IDE, this makes the whole header row in the file properties dialog quite superfluous because it effectively doesn't do anything, so I'm guessing this is still pending implementation?

    >>Could you share your modified .jsproj file?

    For the purpose of testing this, I looked at a .vcxproj file and adapted the .jsproj accordingly:

    <Content Include="css\testing.css"/>
    <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">true</ExcludedFromBuild>
    <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">false</ExcludedFromBuild>
    </Content>

    It looks like the .jsproj doesn't understand the ExcludedFromBuild tag in this context. This is reflected by the fact that I can change between build configurations in the upper part of a file properties dialog in a WinJS project and it won't have any effect on the file properties set in the bottom part of the dialog which will always be the same across all build configurations.

    >>>> Also, I cannot find Microsoft.Build.xsd. Where does it reside and do you even think it would help me to understand the .jsproj file format regarding the issue at hand?

    >>You can find it here on disk: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Build.xsd. I don't think it will necessarily help you understand the .jsproj file format. The .jsproj file format uses the same schema and properties and such as any other MSBuild project. The best way is to use MSDN docs to understand MSBuild and understanding the .jsproj file will just follow.

    Thank you for the clarification. In this path I also found the MSBuild executable which - at least in the VisualStudio 11 Beta we use for our WinJS project - isn't available from the command line.
    Edit: after setting my PATH variable like I found in the "Developer Command Prompt" version, I can successfully build the package from the command line.

    Do you perchance know how to run the generated package (via WWAHost, I presume) from the command line? I remember reading somewhere on the forums that it was possible but couldn't find any specific information on the subject. For an automated testing process, it would be necessary to programmatically start the application and it would be fine if it required disabling some security mechanism, using a special developer tool or something along the lines on the test environment VM.

    • Edited by Marcus Ilgner Thursday, March 01, 2012 10:34 AM Command line build now working as expected
    Thursday, March 01, 2012 9:49 AM
  • I will get back to you on the .jsproj ExcludedFromBuild question soon.

    As for running the generated package, you will find a .bat file in the \AppPackages folder. Double-click that, switch your screen to the Metro screen where you will find a tile with your package name, click that tile, and your package will run.

    Thursday, March 01, 2012 6:10 PM
  • Regarding the ExcludedFromBuild question: it is in fact not supported in WinJS projects. A workaround is the following:
    <
    Content Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'" Include="css\test.css" />   
    <
    None Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'" Include="css\test.css" />

    • Marked as answer by Marcus Ilgner Friday, March 02, 2012 8:34 AM
    Thursday, March 01, 2012 9:51 PM
  • I know that I can install the application via the generated .bat file, but manually clicking the application tile isn't really an option since the app should be automatically started via the CI server.

    Friday, March 02, 2012 8:38 AM