Creating a NuGet package for Windows 7.1 SDK - visual-studio-2010

I've been creating NuGet packages for some of my libraries. The goal is to have my Jenkins build server use a CoApp .autopkg script to build a NuGet package that I can then use in other projects.
The issue is that the build server uses the standalone Windows 7.1 SDK rather than Visual Studio 2010. I guess this is a separate Platform Toolset? So essentially, I can't use the packages compiled by the build server in my Visual Studio 2010 projects? Do people normally install a copy of Visual Studio on their build servers?

Are you using nuget.exe pack to create packages? You shouldn't need visual studio to run nuget.exe.
Here is a link to nuget.exe pack command reference - http://docs.nuget.org/docs/reference/command-line-reference#Pack_Command

Related

How to build .vdproj in Azure DevOps pipeline

I am using windows self hosted agent with VS 2019 build tools installed. But in the build pipeline, I am unable to build ".vdproj" (.net framework 3.5) project. Please let me know whether installing of visual studio is the only option or any alternative approach available.
Thanks.
To build the .vdproj project, you will have to use devenv command to build the project.
Devenv.exe is the central Integrated Development Environment (IDE) for Visual Studio.
So you need to install the Visual Studio to get the Devenv.exe to build the project.
In Azure DevOps, you can add the Command Line Task and run the following command to build the .vdproj project.
For example:
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\devenv.exe" MyProjectDir\MySolution.sln /Rebuild Release

Xamarin vstool build cannot find NuGet MSBuild targets

Background
I recently converted my Xamarin.Forms app from PCL to Net Standard format.
All of my projects now use PackageReference in the csproj file. Which means no more package.config or package.json.
We use TFS 2015 to build, sign, package our .ipa and .apk files. After conversion, the default MSBUILD build steps do not work as they look for mdtool and the new Visual Studio has vstool instead. So, I updated the build steps to use new tools via command line.
All my projects are NetStandard now (including iOS and Android).
Issue
I can successfully restore NuGet packages using restore MySolution.sln -force on Mac build server. But when I run vstool build MySolution.sln after that, I get this error:
error: NuGet packages need to be restored before building. NuGet
MSBuild targets are missing and are needed for building. The NuGet
MSBuild targets are generated when the NuGet packages are restored.
I am able to successfully run the nuget restore and vstool build locally on the build machine. But only when TFS runs the command via agent, it shows that error message.
Setup
Builds: TFS 2015 on Mac agent running Visual Studio 7.5
According to the error and your description, you need also check if your build agent has corresponding capability to support vsbuild.
Take a look at this related question MacOS - Visual Studio Support and give a try with this workaround:
As a work around we set the Xamarin.iOS variable manually in the build
agent and changed the mdtool path in the Xamarin iOS Build step to
"/Applications/Visual Studio.app/Contents/MacOS/vstool".
Besides you could also try to use the suggestion from Matt in the comment above.
Ok. I was finally able to get a successful iOS build on Mac server. This is the setup that works,
Using PackageReference in iOS .csproj
No package.config, project.json, or AssemblyInfo.cs file.
Running nuget restore .sln before building the iOS project.
Build solution using <path-to-vstool>\vstool build .sln -c:<configuration>
Now, I am working on the Windows machine for Android setup. Once I have that working, I will post my findings here.

Universal application with visual studio online

I'm currently setting up project in Visual Studio Online (VSO) and having troubles with setting up automated build.
My solution contains projects targeted as Universal Windows
VSO uses msbuild to run my project.
During build I see strange error messages like:
Error CS0518: Predefined type 'System.Void' is not defined or imported
Error CS0518: Predefined type 'System.Object' is not defined or imported
Error CS0246: The type or namespace name 'Uri' could not be found (are you missing a using directive or an assembly reference?)
msbuild is invoked with following parameters:
C:\Program Files (x86)\MSBuild\14.0\bin\amd64\msbuild.exe "C:\a\b0d9e3fd\test\src\Shipping.sln" /nologo /m /nr:false /fl /flp:"logfile=C:\a\b0d9e3fd\test\src\Shipping.sln.log" /dl:CentralLogger,"C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agent\worker\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll"*ForwardingLogger,"C:\LR\MMS\Services\Mms\TaskAgentProvisioner\Tools\agent\worker\Microsoft.TeamFoundation.DistributedTask.MSBuild.Logger.dll" /p:Platform=Win32 /p:TargetVersion=”Windows10” /p:TargetPlatformVersion=”10.0.10010.0” /p:platform="any cpu" /p:configuration="release" /p:VisualStudioVersion="14.0"
What's wrong with this? Are there any other additional parameters required to build universal windows app with msbuild?
Are you targeting the Windows 10 SDK? If so note that it is not installed on the TFS hosted build servers. Consequently you will not be able to build apps that use the Windows 10 SDK. You can see the complete list of installed software here.
Just found the solution.
If build UWP app, from VS it resolves NuGet dependencies automatically. By default VS 10 projects uses NuGet of 3rd version, which was not installed on our build machine. That's why we had such issue.
The problem was fixed with installing NuGet 3 onto build agent and configure script which resolves NuGet packages before build.
If you can't customize the software of your build agent (aka: the free Hosted Agent) another work-around is to just check in your project.lock.json file.
This is because NuGet v2.8.7 can read both project.json and project.lock.json files but it cannot generate a project.lock.json file from a project.json file.
And, if at such a time Microsoft updates NuGet for their default build agents, you can just remove it from source-control and let it generated automatically as part of Nuget -restore. Until then, just check it in.

Is there a nuget.exe command-line equivalent of Uninstall-Package?

I'm working on a NuGet package that installs a bunch of content - views, scripts, CSS files - into a web application, and trying to improve the change-compile-test cycle. I have two projects - the framework itself ("Package") and the demo web app that consumes it ("Website")
What I need to do as part of the Visual Studio build process is:
(as part of Package post-build) Nuget pack Package.nuspec -OutputDirectory ..\pkg\
(as part of Website pre-build) Nuget uninstall Package
(as part of Website pre-build) Nuget install package -source ..\pkg\
The problem is - there doesn't seem to be any command-line equivalent of doing Uninstall-Package from the NuGet Package Manager console. Am I missing something?
No there isn't currently.
Also, nuget.exe install doesn't really install anything. What nuget.exe install really does is nuget.exe restore: it restores the extracted package in the output directory. It doesn't run the PowerShell hooks (e.g. install.ps1) and it doesn't modify any target project (as there's none being targeted).
There is a way but using neither Visual Studio nor NuGet.exe. Using a custom build of SharpDevelop you can install and uninstall NuGet packages from the command line and have their PowerShell scripts run.
This custom build of SharpDevelop and its NuGet addin allows you to run the commands, such as Install-Package and Uninstall-Package, from PowerShell but outside of Visual Studio.
The limitations are that it needs SharpDevelop to be available and it also does not support any PowerShell scripts that are Visual Studio specific.

Building deployment package with Visual Studio 2012

We were building a Visual Studio 2010 solution with the following msbuild command:
msbuild MySolution.sln /p:DeployOnBuild=true;DeployTarget=Package
This command built the solution and created the deployment packages for web projects in the solution.
But after we've migrated to Visual Studio 2012 this command doesn't work anymore. The solution is built, but no deployment packages are created.
How to fix it?
The problem was exactly the same as in this question.
Copying *C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Web** from a local machine to a remote CI server.
I use this manually, should be a matching msbuild parameter
Using the Publish Web Wizard to Create a Deployment Package

Resources