Building a .xap file from command line - c#

Is it possible to build a .xap file from the command line like you would build a .cs file from csc.exe?

You can use MSBuild to build a project or a solution. From the Visual Studio Command Prompt, change your working directory to where your Solution / Project is:
>MSBuild YourSolution.sln
And now it is built. You do need the Windows Phone 7 Development tools installed on the machine for this to work.

You can also just invoke devenv from the visual studio command prompt that is installed as part of the SDK. MSDN has the relevant documentation.

Related

How to compile my c# solution with msbuild from command line

I have a c# solution (open source, available here: https://github.com/tzachshabtay/MonoAGS) which I can compile fine from Visual Studio 2017 (Dot net framework) and from VS for Mac (Mono). I can also compile it with msbuild on Travis CI successfully on both linux and mac (https://github.com/tzachshabtay/MonoAGS/blob/master/.travis.yml).
What I can't do, is compile it on command-line from Windows 10 on my local machine. I'd like to be able to compile it both for DotNet Framework and Mono.
So I tried using MSBuild from both the mono installation and from the Build Tools for Visual Studio 2017 (note: I want to be able to install on windows even if vs2017 is not installed, though on the local machine vs2017 is installed, don't know if it matters).
Both installations are for the latest versions as of today.
This is the error I get from msbuild on mono (PATH was set to %programfiles(x86)%\Mono\bin):
Project "C:\Github\MonoAGS\MonoAGS.sln" (1) is building "C:\Github\MonoAGS\Source\Tests\Tests.csproj" (2) on node 1 (default targets).
Project "C:\Github\MonoAGS\Source\Tests\Tests.csproj" (2) is building "C:\Github\MonoAGS\Source\AGS.API\AGS.API.csproj"
(3) on node 1 (GetTargetFrameworks target(s)).
C:\Program Files\dotnet\sdk\2.1.4\Sdks\Microsoft.NET.Sdk\Sdk\Sdk.props(29,11): error MSB4226: The imported project "C:\
Program Files (x86)\MSBuild\15.0\Microsoft.Common.props" was not found. Also, tried to find "15.0\Microsoft.Common.prop
s" in the fallback search path(s) for $(MSBuildExtensionsPath) - "C:\Program Files (x86)\MSBuild" . These search paths
are defined in "C:\Program Files\Mono\lib\mono\msbuild\15.0\bin\MSBuild.dll.config". Confirm that the path in the declaration is correct, and that the file exists on disk in one of the search paths. [C:\Github\MonoAGS\Source\AGS.
API\AGS.API.csproj]
And here's the error I get from msbuild from build tools (PATH was set to %programfiles(x86)%\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin):
Project "C:\Github\MonoAGS\Source\Tests\Tests.csproj" (2) is building "C:\Github\MonoAGS\Source\AGS.API\AGS.API.csproj" (3) on node 1 (GetTargetFrameworks target(s)).
C:\Github\MonoAGS\Source\AGS.API\AGS.API.csproj : error MSB4247: Could not load SDK Resolver. A manifest file exists, but the path to the SDK Resolver DLL file could not be found. Manifest file path 'C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\SdkResolvers\Microsoft.Build.NuGet
SdkResolver\Microsoft.Build.NuGetSdkResolver.xml'. SDK resolver path: C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\Common7\IDE\CommonExtens
ions\Microsoft\NuGet\Microsoft.Build.NuGetSdkResolver.dll
As for the mono error, the MSBuild\15.0 folder exists but Microsoft.Common.props is not there (and I couldn't find it anywhere else on that machine).
As for the build tools error, the CommonExtensions folder exists but there is no Microsoft folder in it.
The command I'm trying is:
msbuild /p:Configuration=DEBUG /p:Platform="Any CPU" MonoAGS.sln
Why doesn't it work? What am I missing?
Thanks.
How to compile my c# solution with msbuild from command line
For the build tools error, you should install the component NuGet package manager by Visual Studio Installer:
When we use the Visual Studio build tool to build our project, we also need to install some of the necessary components for our project.
For the mono error, since I do not have mono ENV, I could not specify the directly reason for that error, if possible, you can try to install Mono framework. If it not helps, you can open a new thread with mono and msbuild tags.
Update:
How do I install it with command-line, btw (for setting up a script)?
Yes, you can use vs_buildtools.exe to install that component ID Microsoft.VisualStudio.Component.NuGet:
vs_buildtools.exe --add Microsoft.VisualStudio.Component.NuGet --quiet
Note: You should rename vs_buildtools__2048890300.15156xxxx.exe to vs_buildtools.exe, then use vs_buildtools.exe to install it.
Check the Visual Studio Build Tools 2017 component directory and Use command-line parameters to install Visual Studio 2017 for some more details.
Hope this helps.

Build an executable file without Microsoft Visual Studio from project file

I don't have MS Visual Studio installed and can't install it due to financial/legal reasons. I've inherited an executable file built with Visual Studio using C#. It isn't working as planned. I can fix the problem by changing 1 line of code. I have done so, but now I don't know how to re-build the project into an executable without Visual Studio.
I've tried running the following code from the command prompt:
>C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe
/out:exchange.exe exchange.csproj
Am I on the right track?
Edit: This question is different from this question because here I ask about building and compiling a whole project... not just a .cs file.
I would suggest installing Visual Studio Community edition (free)
But, if you just want to build using msbuild through the commandline the simplest way would be (assuming you navigated to where msbuild is or have the env path set):
msbuild "C:\Users\Something\Documents\Visual Studio 2015\Blah path\Hello.csproj"
Building (then running) a simple console app that prints hello with the above:
You can use MonoDevelop for compiling your C# project.

Error in Visual Studio 2015 When Add New WebForm

When I add new WebForm to my project, I get the following error:
Could not load file or assembly
'Microsoft.VisualStudio.JSLS,Version=14.0.0.0 , Culture=neutral ,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.the system
can not find the file specified.
I tried to create new website project and I tried to reinstall VS 2015 but this did not help.
This is a known bug with Visual Studio 2015. The officially-endorsed solution from Microsoft has been posted on MSDN:
If the “Tools for Universal Windows Apps Development” are still installed:
Go to Programs and Features, select Visual Studio 2105, click Change.
In Visual Studio setup, click Modify.
Deselect the feature “Tools for Universal Windows App Development”
Select “Tools for Universal Windows App Development” again, and click Update.
If you have already uninstalled the “Tools for Universal Windows Apps Development”:
Reinstall “Tools for Universal Windows App Development”
Or take the following steps to reinstall the JavaScript project system and language service:
a. Download the installer for your edition of Visual Studio, e.g.,
vs_community.exe.
b. Open a CMD window, and run the following command:
vs_community.exe /modify /installselectableitems JavaScript_Hidden
/passive
A temporary solution:
Shut down Visual Studio and reinstall the following package from the DVD or ISO:
x:\packages\JavaScript_LanguageService\JavaScript_LanguageService.msi
A better solution, endorsed by Microsoft, has been posted.
Remove the update received for visual studio TypeScript on 11/08/2015. it seems to be buggy. After removing TypeScript update, my VS is working fine ;-)
and if you try to reinstall x:\packages\JavaScript_LanguageService\JavaScript_LanguageService.msi from the installation package, soon or later you will face one more problem that "Something went wrong.. may be because of a extension.."
Easiest way is to remove TypeScript update for now. TypeScript future update may fix the problem.
OR
Run command prompt as administrator.
CD C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE
devenv /updateconfiguration
devenv /clearcache

Dotfuscator post build for visual studio setup project VS 2010

I am using Visual Studio 2013. I have a .NET application that is getting deployed via Visual Studio Setup Project. Right now I have the Primary Output of the application begin used in the setup project. I want to use the Dotfuscator tool to obfuscate my code and then used the dotfuscated output for my setup project. Can someone lead me in the right direction?
I have tried the following
1: On my application post-build event, pass my .xml configuration file from Dotfuscator to the Dotfuscator application. This created an obfuscated exe, but it was still deploying the regular exe with my setup project
On my application post-build event, pass my exe to the Dotfuscator command line tool with the community edition...it would create a obfuscated exe in the Dotfuscated folder and then copy it over to my Release folder. However, the setup project was still deploying the regular exe with my setup project.
Any suggestions?
Found the answer via another thread...I was not aware the Visual Studio Setup Project pulled the 'Primary Output' from the obj folder instead of the bin folder. I copied by obfuscated exe to the obj folder before the setup project was built and this worked.

Run a .cs file - visual studio 2012

Hi im starting to learn c# just now with visual studio 2012 and windows 8, and the tutorial has given some .cs files and not explained how to run them. It is all command line stuff in this tutorial. This stack overflow answer gave the most easy-sounding way of doing it (in response to a similar question by someone else).
If you already installed Visual Studio, just: Click Start, point to
All Programs, point to Microsoft Visual Studio, point to Visual Studio
Tools, and then click Visual Studio Command Prompt and there you have
your command line box where you compile as follows:
csc PathToYourCsSource
I cannot find visual studio tools. I typed it into the search in windows 8. Thanks
It is easier to: Run Visual studio -> Make a new C# console project.
This makes a project with a simple Program.cs file. You can just copy/paste in that, and run the project my clicking F5.
"Visual Studio Tools" is the name of the folder in the All Programs list, not the name of an item you can find by searching. You can search for "Developer Command Prompt for VS2012" (or some portion of that) instead.
I'd recommend that instead, you work with your .cs file as part of a project in Visual Studio. It's easy to create and run a Console Application from the IDE.
You can also use tools like Linqpad to run snippets of code so you don't have to use the bloat of an entire Visual Studio solution/project.
1.
in visual studio directory go to Common7>Tools>Shortcuts>Developer Command Prompt for VS2013 run this ,type csc programName.csc for compiling
and programName for run
Make sure to change the directory of console to your program path
2.
In visual studio create new C# console application and write there ,for run go to menu debug>Start Debugging

Categories

Resources