Add files/folders to a visual studio project using command line tool - file

Is there a way to automatically add/include new files/folders into a Visual Studio project or to add/include them using a command line tool?

You can access Visual Studio automation from VB Script. See the following sample .vbs file that can be run as an executable:
Dim dte
Dim project
Set dte = CreateObject("VisualStudio.DTE.11.0")
dte.Solution.Open("C:\Users\sv\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1.sln")
For Each project In dte.Solution.Projects
If project.Name = "ConsoleApplication1" Then
project.ProjectItems.AddFromFile("C:\Users\sv\Documents\Visual Studio 2012\Projects\ConsoleApplication1\ConsoleApplication1\1.txt")
project.Save(project.FullName)
End If
Next
dte.Solution.Close()

Related

MSBuild opens a new instance of Visual Studio

We have been using Visual studio 2010 - 2013 on the build server using the following MSBuild command so far:
Set msBuilder=%windir%\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe
However recently we moved to VS 2015, and had to uninstall all other VS versions (for saving space), and used the following build location (partially also to cater compilation of C# 6.0 features):
Set msBuilder =%ProgramFiles(x86)%\MSBuild\14.0\Bin\MSBuild.exe
This seems to work for most of the VS Solutions we have,however for one particular VS solution, when we execute this line:
Set doSolutionBuild=%msBuilder% MySolution.sln /t:clean;Build /p:Configuration=Release;Architecture=x86;Platform=x86 /v:n
it opens and instance of VS 2015 of the same project on the build server and the build process just hangs there in the command prompt.
Can anyone explain how we could resolve this?

Cordova project and windows platform

I have a cordova project and I added windows platform but when I run the project I have this error:
MSBuild v4.0 is not supported, aborting.
Error: AppPackages doesn't exists
Try to set OS environment variable
VSINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\
which points to your Visual Studio folder with MSBuild directory.
You have of install Microsoft Build Tools:
https://www.visualstudio.com/downloads/
Navigate to Other Tools and Frameworks
Download Build Tools for Visual Studio 2017
After, set OS environment variable VSINSTALLDIR = C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\ which points to your Visual Studio folder with MSBuild directory

SketchFlow Template for Windows Phone doesn't work with Blend for Visual Studio

I am trying to use the SketchFlow Template for Windows Phone (http://wp7sketchflow.codeplex.com) with Blend for Visual Studio 2013 and when I try to create a project with the template I get this error:
New Project failed. Could not find file "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Blend
Preview\ProjectTemplates\en\CSharp\WindowsPhone\WindowsPhone\csWindowsPhonePrototype.zip[ControlLibrary\AssemblyInfo.cs].
I have looked inside the directory and the file does file exist. Does anyone have a solution? The only other stuff I found is http://wp7sketchflow.codeplex.com/discussions/429011.
Thanks,
I've also posted to that thread with a solution. Which I will also add here.
I've posted a fix for using this template with SketchFlow that ships in Blend/VS2013 (may work in 2012 but I didn't test).
Please read my instructions I've tried to be a clear as possible.
You WILL need to download and install the SketchFlowWP7.zip file from this codeplex (I also provide a copy in the link below).
Extract SketchFlowWP7.zip and run the SketchFlowWP7.msi to install.
When it prompts where to install choose the path to your copy of Blend. For instance for VS2013 it's default path is "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend"
Next you will need to navigate down into the following folder "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\ProjectTemplates\en\CSharp\WindowsPhone"
Here you will find a file names csWindowsPhonePrototype.zip, delete it. Yes really delete it, you are going to be replacing it's contents in the next steps.
Download the csWindowsPhonePrototype.zip from the following linkg - http://sdrv.ms/1hED9Cm
Extract the contents of csWindowsPhonePrototype.zip and you will have a folder called csWindowsPhonePrototype
Move the extracted folder into the "C:\Program Files (x86)\Microsoft Visual Studio 12.0\Blend\ProjectTemplates\en\CSharp\WindowsPhone" directory. PLEASE make sure that you don't have a folder called csWindowsPhonePrototype inside of it, if you do it's that child folder you need to move.
Now when you fire up Blend you should see an option for SketchFlow for Windows Phone.

how to change file path of vsdbcmd.exe of visual studio for database deployment

I try to deploy a visual studio database project, but error below:
"C:\Program Files\Microsoft Visual
Studio 10.0\VSTSDB\Deploy\vsdbcmd.exe"
/ManifestFile:"D:\MyAppDB\sql\debug\MyApp.DB.deploymanifest"
/a:Deploy /dsp:sql
/script:"D:\MyAppDB\sql\debug\MyApp.DB.sql" /cs:"Data
Source=.\SQLEXPRESS;Integrated
Security=True;Pooling=False"
/p:GenerateDropsIfNotInProject=True
/p:BlockIncrementalDeploymentIfDataLoss=False
/p:TargetDatabase=MyAppBranchNational
/p:SqlCommandVariablesFile="D:\MyAppDB\Properties\Database.sqlcmdvars"
/p:IgnorePermissions=True
/p:GenerateDeployStateChecks=False
/dd:+ The system cannot find the
path specified.
The file vsdbcmd.exe is in
F:\Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy
not in
"C:\Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy"
How to change the file path, so the database project will use the correct file.
Thanks in advance!!
Temporary solution:
I copied the folder below:
F:\Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy (9MB)
to
C:\Program Files\Microsoft Visual Studio 10.0\VSTSDB\Deploy
and it works.
Meanwhile, welcome to any better solution.
You may try this:
"%vs100comntools%....\vstsdb\deploy\vsdbcmd.exe"
if you installed vs2008, then use "%vs90comntools%"
to find out all environment variables, open a command prompt and type "set"; or "set v" to show all variables started with "v".

Creating Silverlight 3 applications with F#

Is there an easy way to create Silverlight 3 applications with F# (October CTP)?
I have seen the F# for Silverlight, but that only works with the May CTP.
I am using Visual Studio Integrated Shell 2008.
It is possible to use the May CTP templates with the October CTP version of F#
Create your new project, then unload it and edit the hint path for the FSharp.Core.dll to point to the October CTP,
<HintPath>$(ProgramFiles)\fsharp-1.9.7.8\Silverlight\2.0\bin\FSharp.Core.dll</HintPath>
then reload the project and build.
You do have to package the .xap file manually by e.g. using the chiron tool (or just zipping and renaming)
The AppManifest.xaml file looks like
<Deployment xmlns="http://schemas.microsoft.com/client/2007/deployment"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
RuntimeVersion="3.0.40818.0"
EntryPointAssembly="astroclock-fs"
EntryPointType="astroclock.fs.MyApp">
<Deployment.Parts>
<AssemblyPart x:Name="astroclock-fs" Source="astroclock-fs.dll" />
<AssemblyPart x:Name="FSharp.Core" Source="FSharp.Core.dll" />
</Deployment.Parts>
</Deployment>
where you fill in your own assembly name and entrypoint instead of mine
Create a folder in $(ProjectDir) to hold all the files to be packaged and copy C:\Program Files\FSharp-1.9.7.8\Silverlight\2.0\bin\FSharp.Core.dll into it, along with the AppManifest.xaml above
Create an empty file null.py in the folder to keep chiron quiet if you are using that tool
Add the following post-build steps
cd $(ProjectDir)
copy /y $(OutDir)$(TargetFileName) [your directory with all the output]
"C:\Program Files\IronPython 2.0\Silverlight\bin\chiron.exe" /d:[your directory with all the output] /z:app.xap
Create a test page to load app.xap
Build project
Load page in browser and enjoy
ADDED
You can make a permanent fix for the hint path needed to find FSharp.Core.dll by editing the template in C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplatesCache\FSharp\Silverlight\SilverlightLibrary3.zip\SilverlightLibrary.fsproj (and probably the version of the file in C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\FSharp\Silverlight\SilverlightLibrary3.zip just to be certain).
And a working proof of concept (source and everything bundled into the xap) here.
Looks like I got to wait for VS 2010.

Resources