MSBuild to build Release and QA at same time? - visual-studio-2012

I have a working msbuild script in TeamCity which builds the Release configuration. I also need it to build the "QA" configuration and copy it to the QA folder. Can this be done in one script, or do I need multplie scripts?
<?xml version="1.0" encoding="utf-8" ?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<SolutionName>AOP</SolutionName>
<SolutionFile>AOP.sln</SolutionFile>
<ProjectName>AOP.Web</ProjectName>
<ProjectFile>AOP.Web\AOP.Web.csproj</ProjectFile>
</PropertyGroup>
<Target Name="Build" DependsOnTargets="BuildPackage;CopyOutput" />
<Target Name="BuildPackage">
<MSBuild Projects="$(SolutionFile)" ContinueOnError="false" Targets="Rebuild" Properties="Configuration=$(Configuration)" />
<MSBuild Projects="$(ProjectFile)" ContinueOnError="false" Targets="Package" Properties="Configuration=$(Configuration)" />
</Target>
<Target Name="CopyOutput">
<ItemGroup>
<PackagedFiles Include="$(ProjectName)\obj\$(Configuration)\Package\PackageTmp\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="#(PackagedFiles)" DestinationFiles="#(PackagedFiles->'c:\devDeploy\AOP\$(Configuration)\%(RecursiveDir)%(Filename)%(Extension)')"/>
</Target>
</Project>

If its just the value of configuration property which is different for QA, may be you can add another step in the teamcity build and call the same MSBUild script with the QA configuration value. Something like:
msbuild.exe YourScript.proj /p:Configuration=DEBUG
Alternatively you can try editing your script to something like:
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Release</Configuration>
<QAConfiguration Condition=" '$(Configuration)' == '' ">QAConfig</QAConfiguration>
<SolutionName>AOP</SolutionName>
<SolutionFile>AOP.sln</SolutionFile>
<ProjectName>AOP.Web</ProjectName>
<ProjectFile>AOP.Web\AOP.Web.csproj</ProjectFile>
</PropertyGroup>
<Target Name="Build" DependsOnTargets="BuildPackage;CopyOutput;BuildQAPackage;CopyQAOutput" />
<Target Name="BuildPackage">
<MSBuild Projects="$(SolutionFile)" ContinueOnError="false" Targets="Rebuild" Properties="Configuration=$(Configuration)" />
<MSBuild Projects="$(ProjectFile)" ContinueOnError="false" Targets="Package" Properties="Configuration=$(Configuration)" />
</Target>
<Target Name="CopyOutput">
<ItemGroup>
<PackagedFiles Include="$(ProjectName)\obj\$(Configuration)\Package\PackageTmp\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="#(PackagedFiles)" DestinationFiles="#(PackagedFiles->'c:\devDeploy\AOP\$(Configuration)\%(RecursiveDir)%(Filename)%(Extension)')"/>
</Target>
<Target Name="BuildQAPackage">
<MSBuild Projects="$(SolutionFile)" ContinueOnError="false" Targets="Rebuild" Properties="Configuration=$(QAConfiguration)" />
<MSBuild Projects="$(ProjectFile)" ContinueOnError="false" Targets="Package" Properties="Configuration=$(QAConfiguration)" />
</Target>
<Target Name="CopyQAOutput">
<ItemGroup>
<PackagedFiles Include="$(ProjectName)\obj\$(QAConfiguration)\Package\PackageTmp\**\*.*"/>
</ItemGroup>
<Copy SourceFiles="#(PackagedFiles)" DestinationFiles="#(PackagedFiles->'c:\devDeploy\AOP\$(QAConfiguration)\%(RecursiveDir)%(Filename)%(Extension)')"/>
</Target>

Related

Azure functions runtime exception, the type initializer for system data sqlclient excetion, Unable to load DLL 'sni.dll'

I am using aspnet core 3.0 and azure function v3-preview with system.data.sqlclient version 4.7.0
When i try to run azure function(on both service queue trigger and time trigger) it gives below error :
The type initializer for 'System.Data.SqlClient.TdsParser' threw an exception. The type initializer for 'System.Data.SqlClient.SNILoadHandle' threw an exception. Unable to load DLL 'sni.dll' or one of its dependencies: The specified module could not be found.
I tried solutions from below links but didn't work:
1. Azure Function - System.Data.SqlClient is not supported on this platform
2. https://github.com/Azure/app-service-announcements-discussions/issues/9
I tried using "Microsoft.Data.SqlClient" for aspnetcore 3.0 But still the same exception occurs while running Azure function on Azure portal.
Please help !
Here is csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.0</TargetFramework>
<AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.30-beta2" />
<PackageReference Include="runtime.native.System.Data.SqlClient.sni" Version="4.6.0" />
<PackageReference Include="System.Data.SqlClient" Version="4.7.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<!-- For publish --><!--
<ItemGroup>
<None Include="$(USERPROFILE)\.nuget\packages\\microsoft.data.sqlclient\1.0.19249.1\runtimes\win\lib\netcoreapp2.1\microsoft.Data.SqlClient.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
--><!-- For local debug --><!--
<Target Name="CopyToBin" BeforeTargets="Build">
<Copy SourceFiles="$(USERPROFILE)\.nuget\packages\microsoft.data.sqlclient\1.0.19249.1\runtimes\win\lib\netcoreapp2.1\microsoft.Data.SqlClient.dll" DestinationFolder="$(OutputPath)\bin" />
</Target>-->
<ItemGroup>
<None Include="$(USERPROFILE)\.nuget\packages\\system.data.sqlclient\4.7.0\runtimes\win\lib\netcoreapp2.1\system.Data.SqlClient.dll">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<Target Name="CopyToBin" BeforeTargets="Build">
<Copy SourceFiles="$(USERPROFILE)\.nuget\packages\system.data.sqlclient\4.7.0\runtimes\win\lib\netcoreapp2.1\system.Data.SqlClient.dll" DestinationFolder="$(OutputPath)\bin" />
</Target>
</Project>
Please make sure your azure function meet these criteria in this link.
And here is a workaround provided by others, add the following to your .csproj:
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="copy $(OutDir)$(ProjectName).deps.json $(OutDir)bin\function.deps.json" />
</Target>
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="copy $(PublishDir)$(ProjectName).deps.json $(PublishDir)bin\function.deps.json" />
</Target>
It worked for me by adding below code in csproj file :
<Target Name="PostPublish" BeforeTargets="Publish">
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
</Target>
This line should be taking care of that:
<Exec Command="move $(PublishDir)\runtimes $(PublishDir)\bin" />
reference : github

Using Visual Studio 2017 to develop and debug Electron Node js - Debugger attaches but incorrect application window

Visual Studio community 2017 version 15.9.5
Node JS Version: 10.11.0
Chrome Version: 69.0.3497.106
Electron Version: 4.0.1
Using the modifications to the vs project properties as described here:
https://stackoverflow.com/a/46658784/2388129
as well as here
https://stackoverflow.com/a/35985306/2388129
I am able to attach to the VS debugger and hit breakpoints.
However, the Electron app window doesn't initialize properly. I can only get the app to run properly via node.js interactive window by executing .npm start.
When running under debug config and pressing F5 or Start in VS I get a console window, then I go and attach the debugger. Breakpoints hit, but the Electron app window looks like this:
The project's njsproj file contents are:
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">14.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<Name>GitMon</Name>
<RootNamespace>GitMon</RootNamespace>
<SaveNodeJsSettingsInProjectFile>True</SaveNodeJsSettingsInProjectFile>
<NodeExePath>D:\#Documents\My Open Source Repos\GitMon\node_modules\electron\dist\electron.exe</NodeExePath>
<NodeExeArguments>main.js</NodeExeArguments>
<JavaScriptTestFramework>ExportRunner</JavaScriptTestFramework>
<ScriptArguments>--inspect-brk</ScriptArguments>
<DebuggerPort>5858</DebuggerPort>
<NodejsPort>
</NodejsPort>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>0e3d7742-5973-41e0-8411-97f609c13491</ProjectGuid>
<ProjectHome>.</ProjectHome>
<StartupFile>main.js</StartupFile>
<StartWebBrowser>False</StartWebBrowser>
<SearchPath>
</SearchPath>
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<ProjectTypeGuids>{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}</ProjectTypeGuids>
<StartWebBrowser>True</StartWebBrowser>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Compile Include="main.js" />
<Compile Include="renderer\badgeHandler.js" />
<Compile Include="renderer\directoryPickerCaller.js" />
<Compile Include="renderer\externalLinkHandler.js" />
<Compile Include="renderer\gitStatusResultDOMHandler.js" />
<Compile Include="renderer\mainDivSizeHandler.js" />
<Compile Include="renderer\preloader.js" />
<Compile Include="renderer\sidenav.js" />
<Compile Include="renderer\titlebar.js" />
<Compile Include="renderer\zoomHandler.js" />
<Compile Include="renderer\_requires.js" />
<Compile Include="store.js">
<SubType>Code</SubType>
</Compile>
<Content Include="css\colors.css" />
<Content Include="css\content.css" />
<Content Include="css\preloader.css" />
<Content Include="css\scrollbar.css" />
<Content Include="css\sidenav.css" />
<Content Include="css\titlebar.css" />
<Content Include="index.html">
<SubType>Code</SubType>
</Content>
<Content Include="package.json" />
</ItemGroup>
<ItemGroup>
<Folder Include="css\" />
<Folder Include="renderer\" />
</ItemGroup>
<!-- Do not delete the following Import Project. While this appears to do nothing it is a marker for setting TypeScript properties before our import that depends on them. -->
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\TypeScript\Microsoft.TypeScript.targets" Condition="False" />
<Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsTools.targets" />
</Project>
I appreciate the assistance!
try this
in your main.js
replace this line:
mainWindow.loadFile(`index.html`);
with this
mainWindow.loadURL(`file://${__dirname}/index.html`);
ref:https://www.ryadel.com/en/visual-studio-2017-setup-electron-project-run-hello-world-sample-vs2017-template-quick-start/

How to resolve ArgumentNullException caused by adding <FrameworkReference> to .nuproj project file?

According to the NuProj documentation,
NuGet supports adding references to framework assemblies as well. You can specify those via the FrameworkReference item:
<ItemGroup>
<FrameworkReference Include="System.dll" />
<FrameworkReference Include="System.Core.dll" />
</ItemGroup>
But when I try this (see below), I am getting what looks like an ArgumentNullException — the generated .nuspec file does contain the correct <frameworkAssembly> elements, however:
1>C:\…\MSBuild\NuProj\NuProj.targets(527,5): error : Value cannot be null.
1>C:\…\MSBuild\NuProj\NuProj.targets(527,5): error : Parameter name: folderName
This is part of my .vbproj file:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
…
<PropertyGroup>
<NuProjPath Condition=" '$(NuProjPath)' == '' ">$(MSBuildExtensionsPath)\NuProj\</NuProjPath>
</PropertyGroup>
<Import Project="$(NuProjPath)\NuProj.props" Condition="Exists('$(NuProjPath)\NuProj.props')" />
<PropertyGroup Label="Configuration">
<Id>SomeProject</Id>
<Version>…</Version>
<Title>…</Title>
…
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\SomeProject.vbproj" />
</ItemGroup>
<!-- the next ItemGroup is the one I added manually, as shown in the documentation: -->
<ItemGroup>
<FrameworkReference Include="System.ServiceModel.dll" />
</ItemGroup>
<Import Project="$(NuProjPath)\NuProj.targets" />
</Project>
Am I doing something wrong, or is this a bug with NuProj?
This is an issue with v3.4.3 of Nuget.exe - details here:
https://github.com/NuGet/Home/issues/2648
I was able to resolve this by updating to v3.5.0 - just run > nuget update -self on the command line.

Node js project error in Visual Studio. "The specified path, file name, or both are too long" [duplicate]

This question already has answers here:
Visual Studio 2008 References too long?
(2 answers)
Closed 8 years ago.
I create Blank Express Application in Visual Studio 2013. After it installs npm modules I run it. it works well with no errors.
But if I close solution and than open it again project load failes and I see errors in output window saying
"The specified path, file name, or both are too long. The fully qualified file name must be less than 260".
What should I do fix it?
Update:
csproj file
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">11.0</VisualStudioVersion>
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
<Name>ExpressApp7</Name>
<RootNamespace>ExpressApp7</RootNamespace>
</PropertyGroup>
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<SchemaVersion>2.0</SchemaVersion>
<ProjectGuid>83aac9f6-1094-40fc-8ce9-2ca0fe8ccbac</ProjectGuid>
<ProjectHome>.</ProjectHome>
<StartupFile>app.js</StartupFile>
<SearchPath>
</SearchPath>
<WorkingDirectory>.</WorkingDirectory>
<OutputPath>.</OutputPath>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<ProjectTypeGuids>{3AF33F2E-1136-4D97-BBB7-1795711AC8B8};{349c5851-65df-11da-9384-00065b846f21};{9092AA53-FB77-4645-B42D-1CCCA6BD08BD}</ProjectTypeGuids>
<ProjectView>ProjectFiles</ProjectView>
<NodejsPort>1337</NodejsPort>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>true</DebugSymbols>
</PropertyGroup>
<ItemGroup>
<Compile Include="app.js" />
<Compile Include="routes\index.js" />
<Compile Include="routes\user.js" />
<Content Include="package.json" />
<Content Include="public\stylesheets\style.styl" />
<Content Include="README.md" />
<Content Include="views\index.jade" />
<Content Include="views\layout.jade" />
</ItemGroup>
<ItemGroup>
<Folder Include="public\" />
<Folder Include="public\images\" />
<Folder Include="public\javascripts\" />
<Folder Include="public\stylesheets\" />
<Folder Include="routes\" />
<Folder Include="views\" />
</ItemGroup>
<Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsTools.targets" />
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
<WebProjectProperties>
<UseIIS>False</UseIIS>
<AutoAssignPort>True</AutoAssignPort>
<DevelopmentServerPort>0</DevelopmentServerPort>
<DevelopmentServerVPath>/</DevelopmentServerVPath>
<IISUrl></IISUrl>
<NTLMAuthentication>False</NTLMAuthentication>
<UseCustomServer>True</UseCustomServer>
<CustomServerUrl></CustomServerUrl>
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}" User="">
<WebProjectProperties>
<StartPageUrl>
</StartPageUrl>
<StartAction>CurrentPage</StartAction>
<AspNetDebugging>True</AspNetDebugging>
<SilverlightDebugging>False</SilverlightDebugging>
<NativeDebugging>False</NativeDebugging>
<SQLDebugging>False</SQLDebugging>
<ExternalProgram>
</ExternalProgram>
<StartExternalURL>
</StartExternalURL>
<StartCmdLineArguments>
</StartCmdLineArguments>
<StartWorkingDirectory>
</StartWorkingDirectory>
<EnableENC>False</EnableENC>
<AlwaysStartWebServerOnDebug>False</AlwaysStartWebServerOnDebug>
</WebProjectProperties>
</FlavorProperties>
</VisualStudio>
</ProjectExtensions>
</Project>
There are several path variables in your file which are concatenated to your actual paths.
For example: $(VSToolsPath), $(MSBuildExtensionsPath32), $(MSBuildExtensionsPath)
Also you have realtive paths (which are hard to recognise as paths) like this one:
<WorkingDirectory>.</WorkingDirectory>
I bet your issue comes from here (line 49):
<Import Project="$(VSToolsPath)\Node.js Tools\Microsoft.NodejsTools.targets" />
So check the default paths in VisulaStudio Settings, the custom paths in your project settings and try to move everythin to lower directory level.

Sequencing project/solution build and cmd file executing in custom MSBuild file

I need to tie together a bunch of steps which include building solutions, projects and running .cmd files using a custom MSBuild file.
My first pass at this is below:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<ItemGroup>
<ProjectsToBuild Include="..\Hosts\solution1.sln"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\solution2.sln"></ProjectsToBuild>
<ProjectsToBuild Include="helper1.csproj"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\Sandboxes\helper2.sln"></ProjectsToBuild>
<Exec Include="" Command="CALL GetFiles.cmd"/>
<ProjectsToBuild Include="wix\proc\prod.wixproj"></ProjectsToBuild>
<Exec Command="CALL final.cmd"/>
</ItemGroup>
<Target Name="Build">
<MSBuild Projects="#(ProjectsToBuild)" Targets="Build">
<Output ItemName="ProjectOutputs" TaskParameter="TargetOutputs"/>
</MSBuild>
<Message Text="#ProjectOutputs"/>
</Target>
</Project>
This resulted in an error since the Exec element is in the wrong place.
Basically, I need to build solution1.sln, solution2.sln,helper1.csproj and helper2.sln (in sequence), then, run the file GetFiles.cmd, then build prod.wixproj followed by running the final.cmd file.
I have looked at MSDN (here, here, here), a blog, and browsed through various stackoverflow questions (including this, this, this, this), but none of them quite address what I am trying to do. This is the first time I have ever worked with MSBuild, so it is possible I may have missed something. Will appreciate any pointers...
Since an ItemGroup node can be a child of a Target node, break down those ItemGroup members into separate targets, then use the DefaultTargets attribute to control the sequence in which those are built.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Target1;Target2;Target3" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5" >
<Target Name="Target1">
<Message Text="Target 1" />
</Target>
<Target Name="Target2">
<Message Text="Target 2" />
</Target>
<Target Name="Target3">
<Message Text="Target 3" />
</Target>
</Project>
The build projects are already in the correct order see:
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration>Release</Configuration>
<Platform>AnyCPU</Platform>
</PropertyGroup>
<ItemGroup>
<ProjectsToBuild Include="..\Hosts\solution1.sln"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\solution2.sln"></ProjectsToBuild>
<ProjectsToBuild Include="helper1.csproj"></ProjectsToBuild>
<ProjectsToBuild Include="..\..\Sandboxes\helper2.sln"></ProjectsToBuild>
<ProjectsToBuild Include="wix\proc\prod.wixproj"></ProjectsToBuild>
</ItemGroup>
<Target Name="Build">
<Exec Command="CALL GetFiles.cmd"/>
<Message Text="Build order: %(ProjectsToBuild.Identity)"/>
<MSBuild Projects="#(ProjectsToBuild)" Targets="Build">
<Output ItemName="ProjectOutputs" TaskParameter="TargetOutputs"/>
</MSBuild>
<Message Text="#(ProjectOutputs)"/>
<<Exec Command="CALL final.cmd"/>
</Target>
</Project>
At the start the order of the itemgroup is displayed:
Project "C:\Test\Testcode\build\testcode.msbuild" on node 1 (default targets).
Build:
Build order: ..\Hosts\solution1.sln
Build order: ....\solution2.sln
Build order: helper1.csproj
Build order: ....\Sandboxes\helper2.sln
Build order: wix\proc\prod.wixproj
All done.

Resources