MSBuild unable to find directory in Azure cloudservice csdef file - c#

I have a cloud project with two web roles set up in a directory structure like this :
C:\myWork\myProject\
Solution.sln
\CloudService\CloudService.ccproj
\WebRole1\WebRole1.csproj
\WebRole2\WebRole2.csproj
My cloud service .csdef is :
<ServiceDefinition name="CloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2015-04.2.6">
<WebRole name="WebRole1" vmsize="Small">
<Sites>
<Site name="WebRole1"
physicalDirectory="..\..\..\WebRole1\publish\_PublishedWebsites\WebRole1">
<Bindings>
<Binding name="http"
endpointName="http"
hostHeader="WebRole1.cloudapp.net" />
</Bindings>
</Site>
<Site name="WebRole2"
physicalDirectory="..\..\..\WebRole2\publish\_PublishedWebsites\WebRole2">
<Bindings>
<Binding name="http"
endpointName="http"
hostHeader="WebRole2.cloudapp.net" />
</Bindings>
</Site>
</Sites>
-snip-
When I package the CloudService project in VS2015, the package creates fine with both WebRoles built and within the package as expected. It uploads to Azure and both WebRoles are active and error free.
However, if I build with MSBuild through the command line :
msbuild /t:corepublish;package /p:visualstudioversion=14.0;targetframeworkversion=4.5;roletargetframework=4.5;config
uration=debug
I receive the following error during CorePublish :
CorePublish:
CorePublish: PackageWebRole = True
Publishing starting...
RolePlugins is
Importedmodules is
Publishing to 'Publishapp.publish\'
Creating directory "Publishapp.publish\".
TargetServiceDefinition is Publish\ServiceDefinition.csdef
TargetServiceConfiguration is Publish\ServiceConfiguration.cscfg
Roles is
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\Windows Azure Tools\2.6\Microsoft.WindowsAzure.targets(3003,5): warning : CloudServices68 : No TargetFrameworkVersion specified for role WebRole1. Using .NET framework v4.0 for packaging. [c:\mywork\myproject\CloudService\CloudService.ccproj]
c:\mywork\myproject\CloudService\Publish\ServiceDefinition.csdef : error CloudServices079: Cannot find the physical directory 'c:\mywork\WebRole1\publish\_PublishedWebsites\WebRole1' for virtual path WebRole1/. [c:\mywork\myproject\CloudService\CloudService.ccproj]
Done Building Project "c:\mywork\myproject\CloudService\CloudService.ccproj" (Publish target(s)) -- FAILED.
Done Building Project "c:\mywork\myproject\Solution.sln" (Rebuild;Publish target(s)) -- FAILED.
Done Building Project "c:\mywork\myproject\cloudservice\cloudservice.ccproj" (corepublish;package target(s)) -- FAILED.
As you can see, MSBuild is looking for WebRole1 here : c:\mywork\WebRole1 whereas it should be looking here : c:\mywork\myproject\WebRole1.
So why is packaging the cloud service working inside VS2015, yet not with MSBuild ?

I had a very similar issue, and in my case I had to update the MyProject.Azure.ccproj file so that it was always prefixing the PublishPath with the $(ProjectDir). It was not doing that for TFS build originally. I made them the same for now. Not entirely sure if the example I got here is even relevant anymore.
Before:
<PropertyGroup Condition=" '$(PublishDestinationPath)'=='' and '$(BuildingInsideVisualStudio)'=='true' ">
<!-- When Visual Studio build -->
<PublishDestinationPath>$(ProjectDir)$(OutDir)</PublishDestinationPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(PublishDestinationPath)'=='' ">
<!-- When TFS build -->
<PublishDestinationPath>$(OutDir)</PublishDestinationPath>
</PropertyGroup>
After:
<PropertyGroup Condition=" '$(PublishDestinationPath)'=='' and '$(BuildingInsideVisualStudio)'=='true' ">
<!-- When Visual Studio build -->
<PublishDestinationPath>$(ProjectDir)$(OutDir)</PublishDestinationPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(PublishDestinationPath)'=='' ">
<!-- When TFS build -->
<PublishDestinationPath>$(ProjectDir)$(OutDir)</PublishDestinationPath>**
</PropertyGroup>

Related

MAUI publish fails with error saying pack <packname> not present in workload manifests

I'm trying to publish this Maui project which targets Android 10.
I keep getting the following errors:
dotnet publish -f:net6.0-android -c:Release /p:AndroidSigningKeyPass=blah
MSBuild version 17.3.0+92e088760 for .NET Determining projects to
restore... C:\Program
Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(90,5): error : NETSDKZZZZ: Error getting pack version: Pack
'Microsoft.Android.Ref.29' was not present in workload m anifests.
[C:\git\StockTrackMauiGui\StockTrackMauiGui\StockTrackMauiGui.csproj]
C:\Program
Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(90,5): error : NETSDKZZZZ: Error getting pack version: Pack
'Microsoft.Android.Runtime.29.android-arm' was not present in
workload manifests.
[C:\git\StockTrackMauiGui\StockTrackMauiGui\StockTrackMauiGui.csproj]
C:\Program
Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(90,5): error : NETSDKZZZZ: Error getting pack version: Pack
'Microsoft.Android.Runtime.29.android-arm64' was not pre sent in
workload manifests.
[C:\git\StockTrackMauiGui\StockTrackMauiGui\StockTrackMauiGui.csproj]
C:\Program
Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(90,5): error : NETSDKZZZZ: Error getting pack version: Pack
'Microsoft.Android.Runtime.29.android-x86' was not prese nt in
workload manifests.
[C:\git\StockTrackMauiGui\StockTrackMauiGui\StockTrackMauiGui.csproj]
C:\Program
Files\dotnet\sdk\6.0.400\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Sdk.FrameworkReferenceResolution.targe
ts(90,5): error : NETSDKZZZZ: Error getting pack version: Pack
'Microsoft.Android.Runtime.29.android-x64' was not prese nt in
workload manifests.
[C:\git\StockTrackMauiGui\StockTrackMauiGui\StockTrackMauiGui.csproj]
Here's the content of my csproj file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>net6.0-maccatalyst;net6.0-android29.0</TargetFrameworks>
<TargetFrameworks Condition="$([MSBuild]::IsOSPlatform('windows'))">$(TargetFrameworks);net6.0-windows10.0.19041.0</TargetFrameworks>
<!-- Uncomment to also build the tizen app. You will need to install tizen by following this: https://github.com/Samsung/Tizen.NET -->
<!-- <TargetFrameworks>$(TargetFrameworks);net6.0-tizen</TargetFrameworks> -->
<OutputType>Exe</OutputType>
<RootNamespace>StockTrackMauiGui</RootNamespace>
<UseMaui>true</UseMaui>
<SingleProject>true</SingleProject>
<ImplicitUsings>enable</ImplicitUsings>
<!-- Display name -->
<ApplicationTitle>StockTrackMauiGui</ApplicationTitle>
<!-- App Identifier -->
<ApplicationId>com.kerry.stocktrackmauigui</ApplicationId>
<ApplicationIdGuid>FE258B43-CAF4-425D-94F2-1ED061D420C3</ApplicationIdGuid>
<!-- Versions -->
<ApplicationDisplayVersion>0.79.5</ApplicationDisplayVersion>
<ApplicationVersion>5</ApplicationVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'ios'">14.2</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'maccatalyst'">14.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">29.0</SupportedOSPlatformVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</SupportedOSPlatformVersion>
<TargetPlatformMinVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'windows'">10.0.17763.0</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'tizen'">6.5</SupportedOSPlatformVersion>
<ContentSQLiteInteropFiles>true</ContentSQLiteInteropFiles>
<CopySQLiteInteropFiles>false</CopySQLiteInteropFiles>
<CleanSQLiteInteropFiles>false</CleanSQLiteInteropFiles>
<CollectSQLiteInteropFiles>false</CollectSQLiteInteropFiles>
<FileVersion>0.79.5.0</FileVersion>
<AndroidSigningKeyStore>myapp.keystore</AndroidSigningKeyStore>
<PlatformTarget>AnyCPU</PlatformTarget>
<TargetPlatformVersion Condition="$([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) == 'android'">29</TargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-android|AnyCPU'">
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-ios|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
<AndroidPackageFormat>apk</AndroidPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-ios|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
<AndroidPackageFormat>apk</AndroidPackageFormat>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-maccatalyst|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-maccatalyst|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-windows10.0.19041.0|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-windows10.0.19041.0|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
<AndroidSigningKeyAlias>key</AndroidSigningKeyAlias>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net6.0-android29.0|AnyCPU'">
<EmbedAssembliesIntoApk>False</EmbedAssembliesIntoApk>
<AndroidKeyStore>True</AndroidKeyStore>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net6.0-android29.0|AnyCPU'">
<AndroidKeyStore>True</AndroidKeyStore>
</PropertyGroup>
<ItemGroup>
<!-- App Icon -->
<MauiIcon Include="Resources\AppIcon\appicon.svg" ForegroundFile="Resources\AppIcon\appiconfg.svg" Color="#512BD4" />
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
<MauiImage Update="Resources\Images\dotnet_bot.svg" BaseSize="168,208" />
<!-- Custom Fonts -->
<MauiFont Include="Resources\Fonts\*" />
<!-- Raw Assets (also remove the "Resources\Raw" prefix) -->
<MauiAsset Include="Resources\Raw\**" LogicalName="%(RecursiveDir)%(Filename)%(Extension)" />
</ItemGroup>
<ItemGroup>
<None Remove="appsettings.json" />
<None Remove="Resources\Splash\splashscreen.jpg" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="appsettings.json">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<!-- Splash Screen -->
<ItemGroup>
<MauiSplashScreen Include="Resources\Splash\splashscreen.jpg" Color="#194067" ReSize="true" BaseSize="512,512">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</MauiSplashScreen>
</ItemGroup>
<ItemGroup>
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.0.0" />
<PackageReference Include="Microsoft.Data.Sqlite" Version="7.0.0-preview.7.22376.2" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="7.0.0-preview.6.22324.4" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="6.0.0" />
<PackageReference Include="Zebra.Printer.SDK" Version="2.15.2634" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\StockTrackMaui.Core\StockTrackMaui.Core.csproj" />
<ProjectReference Include="..\StockTrackMaui.Infrastructure\StockTrackMaui.Infrastructure.csproj" />
</ItemGroup>
<ItemGroup>
<MauiXaml Update="Views\Common\BinOrLocation.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
<MauiXaml Update="Views\Common\Message.xaml">
<Generator>MSBuild:Compile</Generator>
</MauiXaml>
</ItemGroup>
</Project>
Here's the content of my AndroidManifest.xml file:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.kerry.stockcountmauigui" android:versionCode="6" android:versionName="v0.79.5">
<application android:allowBackup="true" android:icon="#mipmap/appicon" android:roundIcon="#mipmap/appicon_round" android:supportsRtl="true" android:label="StockCount"></application>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<!--Coarse location is required for android 9 or lower, Fine location for android 11 or lower.-->
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<!--Location for Sqlite database file to be on sdcard-->
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<!-- For discovery or to manipulate Bluetooth settings-->
<uses-feature android:name="android.hardware.bluetooth" />
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
<uses-sdk android:minSdkVersion="29" android:targetSdkVersion="29" />
</manifest>
I installed all of the Android 10 system images
I've run the following commands -- I tend to think ZScaler or Beyond Trust is blocking some internet traffic. Here's the command and the results:
dotnet workload list
Installed Workload Ids Manifest Version Installation Source
--------------------------------------------------------------------------------
android 32.0.448/6.0.400 SDK 6.0.400, VS 17.3.32825.248
maui 6.0.486/6.0.400 SDK 6.0.400
maui-maccatalyst 6.0.486/6.0.400 VS 17.3.32825.248
maui-android 6.0.486/6.0.400 VS 17.3.32825.248
maccatalyst 15.4.447/6.0.400 VS 17.3.32825.248
maui-ios 6.0.486/6.0.400 VS 17.3.32825.248
ios 15.4.447/6.0.400 VS 17.3.32825.248
maui-windows 6.0.486/6.0.400 VS 17.3.32825.248
I'm only targeting android 10 (SDK Platform 29)
I open a DOS window as administrator but Beyond Trust may or may not elevate when needed.
dotnet workload install maui
Inadequate permissions. Run the command with elevated privileges.
So I switch to my "supposedly local admin" account and run the same command
dotnet workload install android
Failed to update the advertising manifest microsoft.net.sdk.android: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.ios: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maccatalyst: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.macos: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maui: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.tvos: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.workload.mono.toolchain: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.workload.emscripten: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Installing pack Microsoft.Android.Sdk.Windows version 32.0.448...
Pack Microsoft.Android.Sdk.Windows version 32.0.448 is already installed.
Writing workload pack installation record for Microsoft.Android.Sdk version 32.0.448...
Installing pack Microsoft.Android.Ref.31 version 32.0.448...
Pack Microsoft.Android.Ref.31 version 32.0.448 is already installed.
Writing workload pack installation record for Microsoft.Android.Ref.31 version 32.0.448...
Installing pack Microsoft.Android.Runtime.31.android-arm version 32.0.448...
Pack Microsoft.Android.Runtime.31.android-arm version 32.0.448 is already installed.
Writing workload pack installation record for Microsoft.Android.Runtime.31.android-arm version 32.0.448...
Installing pack Microsoft.Android.Runtime.31.android-arm64 version 32.0.448...
Pack Microsoft.Android.Runtime.31.android-arm64 version 32.0.448 is already installed.
Writing workload pack installation record for Microsoft.Android.Runtime.31.android-arm64 version 32.0.448...
Installing pack Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm version 6.0.8...
Pack Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm version 6.0.8 is already installed.
Writing workload pack installation record for Microsoft.NETCore.App.Runtime.AOT.Cross.android-arm version 6.0.8...
Installing pack Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64 version 6.0.8...
Pack Microsoft.NETCore.App.Runtime.AOT.win-x64.Cross.android-arm64 version 6.0.8 is already installed.
Writing workload pack installation record for Microsoft.NETCore.App.Runtime.AOT.Cross.android-arm64 version 6.0.8...
Garbage collecting for SDK feature band(s) 6.0.400...
Successfully installed workload(s) android.
I removed many lines of successfully installed packages due to hitting the 30000 character limit
dotnet workload install maui
Failed to update the advertising manifest microsoft.net.sdk.android: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.ios: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maccatalyst: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.macos: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.maui: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.sdk.tvos: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.workload.mono.toolchain: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Failed to update the advertising manifest microsoft.net.workload.emscripten: Unable to load the service index for source https://api.nuget.org/v3/index.json..
Installing pack Microsoft.Maui.Core.Ref.android version 6.0.486...
Pack Microsoft.Maui.Core.Ref.android version 6.0.486 is already installed.
Writing workload pack installation record for Microsoft.Maui.Core.Ref.android version 6.0.486...
Installing pack Microsoft.Maui.Essentials.Runtime.win version 6.0.486...
Pack Microsoft.Maui.Essentials.Runtime.win version 6.0.486 is already installed.
Writing workload pack installation record for Microsoft.Maui.Essentials.Runtime.win version 6.0.486...
Installing pack Microsoft.Maui.Graphics.Win2D.WinUI.Desktop version 6.0.403...
Pack Microsoft.Maui.Graphics.Win2D.WinUI.Desktop version 6.0.403 is already installed.
Writing workload pack installation record for Microsoft.Maui.Graphics.Win2D.WinUI.Desktop version 6.0.403...
Garbage collecting for SDK feature band(s) 6.0.400...
Successfully installed workload(s) maui android.
I removed many lines of successfully installed packages due to hitting the 30000 character limit.
Your assistance is much appreciated.

Using a publish profile with msbuild

I'm trying to use a publish profile with the msbuild command in a PowerShell window on a machine that does not have the full Visual Studio IDE installed. I have tried the following:
msbuild.exe .\Web.Admin.csproj /p:'DeployOnBuild=true;PublishProfile=Default;'
MSBuild.exe .\Web.Admin.csproj /p:PublishProfile=Default /p:VisualStudioVersion=14.0
msbuild.exe .\Web.Admin.csproj /p:PublishProfileRootFolder=C:\Users\username\Projects\Web\Web.Admin\Properties\PublishProfiles /p:PublishProfile=Default
In both cases, the publish profile seems to be ignored. This is the publish profile, generated by Visual Studio (in Properties\PublishProfiles\Default.pubxml):
<?xml version="1.0" encoding="utf-8"?>
<!--
This file is used by the publish/package process of your Web project. You can customize the behavior of this process
by editing this MSBuild file. In order to learn more about this please visit https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>FileSystem</WebPublishMethod>
<PublishProvider>FileSystem</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish />
<LaunchSiteAfterPublish>True</LaunchSiteAfterPublish>
<ExcludeApp_Data>True</ExcludeApp_Data>
<publishUrl>C:\Sites\Test</publishUrl>
<DeleteExistingFiles>True</DeleteExistingFiles>
<PrecompileBeforePublish>True</PrecompileBeforePublish>
<EnableUpdateable>True</EnableUpdateable>
<DebugSymbols>False</DebugSymbols>
<WDPMergeOption>DonotMerge</WDPMergeOption>
</PropertyGroup>
</Project>
The files are not published to the C:\Sites\Test directory specified, as they would be if I ran this with the Publish command in Visual Studio 2017. Instead they go to the project bin directory.
MSBuild Version: 14.0.23107.0

.NET Core 1.1 app with PCL, unable to build on Team services

I have following projects on solution and this works perfectly fine on my local.
However when I check code in Team service and create build it fails.
mainconsole.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp1.1</TargetFramework>
<PackageTargetFallback>portable-net45+win8</PackageTargetFallback>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NETCore.Portable.Compatibility" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\business\business.csproj" />
<ProjectReference Include="..\portableextensibility\portableextensibility.csproj" />
<ProjectReference Include="..\portablelibrary\portablelibrary.csproj" />
</ItemGroup>
</Project>
Build tasks:
command line - tool dotnet, argument - restore
command line - tool dotnet, argument - build
Build fails:
d:\a\3\s\portablelibrary\portablelibrary.csproj(43,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.4\Microsoft\Portable\v4.5\Microsoft.Portable.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
d:\a\3\s\portableextensibility\portableextensibility.csproj(42,3): error MSB4019: The imported project "C:\Program Files\dotnet\sdk\1.0.4\Microsoft\Portable\v4.5\Microsoft.Portable.CSharp.targets" was not found. Confirm that the path in the declaration is correct, and that the file exists on disk.
C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Unable to resolve 'd:\a\3\s\portableextensibility\portableextensibility.csproj' for '.NETCoreApp,Version=v1.1'. [d:\a\3\s\dotnetcompatibility.sln] C:\Program Files\dotnet\sdk\1.0.4\NuGet.targets(97,5): error : Unable to resolve 'd:\a\3\s\portablelibrary\portablelibrary.csproj' for '.NETCoreApp,Version=v1.1'. [d:\a\3\s\dotnetcompatibility.sln] Generating MSBuild file d:\a\3\s\mainconsole\obj\mainconsole.csproj.nuget.g.props. Generating MSBuild file d:\a\3\s\mainconsole\obj\mainconsole.csproj.nuget.g.targets. Writing lock file to disk. Path: d:\a\3\s\mainconsole\obj\project.assets.json Restore failed in 37.7 sec for d:\a\3\s\mainconsole\mainconsole.csproj.
Errors in d:\a\3\s\business\business.csproj
Unable to resolve 'd:\a\3\s\portablelibrary\portablelibrary.csproj' for '.NETStandard,Version=v1.1'.
Errors in d:\a\3\s\mainconsole\mainconsole.csproj
Unable to resolve 'd:\a\3\s\portableextensibility\portableextensibility.csproj' for '.NETCoreApp,Version=v1.1'.
Unable to resolve 'd:\a\3\s\portablelibrary\portablelibrary.csproj' for '.NETCoreApp,Version=v1.1'.
Since the solution contains PCL libraries which currently cannot be built using the dotnet cli, the project has to be built through msbuild instead of the dotnet based commands.
Here is the corrected configuration:
Build Definition
Queue options
Result

MSBuild command line with C# 6.0 code fails to build

I am having an issue getting MSBuild to compile c# 6.0 code, it reports a failure when trying to build expression body syntax, etx.
So I've been creating build project like this for years. I have a powershell script that kicks of an msbuild with some parameters:
msbuild.exe _build\build.proj
/p:Build_Number=1.2.0
/p:Configuration=QA
/p:SolutionName=MPGCS-Api.sln
/ToolsVersion:14.0
I verified that msbuild.exe is coming from C:\Program Files (x86)\MSBuild\14.0\Bin , i did this by going into that folder and specifying the full physical path to the .proj file. I get the same exact errors.
I have been looking for an example on how to setup a MSBuild project file with C# 6.0 with no luck, so this is my basic setup (this is the build.proj file). If I had to guess I am not importing the correct targets, etc. But I am a little lost. Here is my proj file:
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Root>$(MSBuildStartupDirectory)</Root>
<NugetExe>$(Root)\_build\lib\nuget\nuget.exe</NugetExe>
<Build_Number>0.0.0</Build_Number>
<SolutionName></SolutionName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<VisualStudioVersion>14.0</VisualStudioVersion>
</PropertyGroup>
<Target Name="Clean">
<!-- Clean up -->
<ItemGroup>
<FilesToDelete Include="$(Root)\_build\Artifacts\**\*.*" />
<FilesToDelete Include="$(Root)\_build\Published\**\*.*" />
</ItemGroup>
<Delete Files="#(FilesToDelete)" ContinueOnError="false" />
<!-- Ensure directories exists -->
<MakeDir Directories="$(MSBuildProjectDirectory)\Artifacts" Condition="!Exists('$(MSBuildProjectDirectory)\Artifacts')" />
<MakeDir Directories="$(MSBuildProjectDirectory)\Published" Condition="!Exists('$(MSBuildProjectDirectory)\Artifacts')" />
</Target>
<Target Name="Debug" AfterTargets="Clean">
<!-- Diagnostics -->
<Message Text="Diagnostics:"/>
<Message Text="Build Number: $(build_number)" />
<Message Text="Configuration: $(Configuration)" />
<Message Text="VisualStudioVersion: $(VisualStudioVersion)" />
<Message Text="Project root: $(Root)" />
<!-- Restore Nuget Packages -->
<Message Text="Restoring nuget..."/>
<Exec Command="$(NugetExe) restore $(Root)\$(SolutionName)" />
</Target>
<Target Name="GenerateOctopackAPI" AfterTargets="Debug">
<ItemGroup>
<ProjectToBuild Include="$(Root)\MPG.CS.Api\MPG.CS.Api.csproj" />
</ItemGroup>
<MSBuild Projects="#(ProjectToBuild)" ContinueOnError="false" Targets="Rebuild" Properties="
RunOctoPack=true;
Configuration=$(ProjectBuildMode);
Platform=AnyCpu;
TargetFrameworkVersion=$(TargetFrameworkVersion);
VisualStudioVersion=$(VisualStudioVersion);
OctoPackPublishPackageToFileShare=$(Root)\_build\Artifacts;
OctoPackPackageVersion=$(Build_Number);
OctoPackProjectName=UI;
OutputPath=bin\$(ProjectBuildMode)" />
</Target>
</Project>
Here is some info from my "Debug" target, as you can see I am setting the VisualStudioVersion to 14.0 as per some suggestions I read online.
Diagnostics:
Build Number: 1.2.0
Configuration: QA
VisualStudioVersion: 14.0
Project root: C:\dev\mpg\MPGCS-Api
Here is an example error, it's basically failing on c# 6.0 code, if I were to remove c# 6 code, everything will compile:
TicketType.cs(19,28): error CS1002: ; expected [C:\dev\mpg\MPGCS-Api\MPG.CS.Model\MPG.CS.Model.csproj]
TicketType.cs(19,44): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\dev\mpg\MPGCS-Api\MPG.CS.Model\MPG.CS.Model.cs proj]
TicketStatus.cs(16,36): error CS1002: ; expected [C:\dev\mpg\MPGCS-Api\MPG.CS.Model\MPG.CS.Model.csproj]
TicketStatus.cs(16,53): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\dev\mpg\MPGCS-Api\MPG.CS.Model\MPG.CS.Model. csproj]
TicketStatus.cs(16,82): error CS1519: Invalid token '(' in class, struct, or interface member declaration [C:\dev\mpg\MPGCS-Api\MPG.CS.Model\MPG.CS.Model. csproj]
Here is a line it's failing on (C# 6 code):
public bool IsAbbreviated => (Title.ToLower() == "open" || Title.ToLower() == "closed");
I'm at a loss, I thought just using the proper msbuild.exe will allow me to take advantage of c# 6.0. Any help would be greatly appreciated.
If you're running the powershell script on a build server, separate from your dev environment, you will need to make sure that the machine itself can handle C# 6.0. Since it uses a different compiler all together, it wouldn't work if VS 2015 wasn't installed. Alternately, you can add the Microsoft.Net.Compilers nuget package as a dependency to allow VS 2012 and VS 2013 to compile it.

Azure Project build package working from VS, failing from command line with error MSB4096

I have a solution with a Windows Azure Cloud Services project, that compiles fine from VS and command line.
If I try to make a package, it works fine from VS, but fails from command line.
Here is my command line from Powershell:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe .\project.sln --%
/p:Configuration="QA" /p:TargetProfile="CloudQA" /p:Platform="Any CPU" /target:Publish
/nr:false
I have this error:
"C:\CI\project\project.sln" (Publish target) (1) ->
"C:\CI\project\WindowsAzure\WindowsAzure.ccproj.metaproj" (Publish target) (11) ->
"C:\CI\project\WindowsAzure\WindowsAzure.ccproj" (Publish target) (12) ->
(PrepareRoleItems target) ->
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0\Microsoft.WindowsAzure.targets(13
02,5): error MSB4096: The item "C:\CI\project\project.WebAPI\project.WebAPI.csproj" in item list "Projec
tReferenceWithConfiguration" does not define a value for metadata "Name". In order to use this metadata, either qualif
y it by specifying %(ProjectReferenceWithConfiguration.Name), or ensure that all items in this list define a value for
this metadata. [C:\CI\project\WindowsAzure\WindowsAzure.ccproj]
EDIT
Few interesting things:
Here is my csdef file
<WorkerRole name="ProjectWorker" vmsize="ExtraSmall">
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
<Endpoints>
<InternalEndpoint name="InternalEndpoint1" protocol="http" />
</Endpoints>
<ConfigurationSettings>
</ConfigurationSettings>
</WorkerRole>
<WebRole name="Project.Web" vmsize="ExtraSmall">
<Sites>
<Site name="Web">
<Bindings>
<Binding name="http" endpointName="http" />
</Bindings>
</Site>
<Site name="Api" physicalDirectory="..\..\..\Project.WebAPI">
<Bindings>
<Binding name="http" endpointName="http81" />
</Bindings>
</Site>
</Sites>
<Endpoints>
<InputEndpoint name="http" protocol="http" port="80" />
<InputEndpoint name="http81" protocol="http" port="81" />
</Endpoints>
<Imports>
<Import moduleName="Diagnostics" />
</Imports>
</WebRole>
As you can see, I have two websites on one WebRole.
Now, let's have a look at the ccproj file:
<ItemGroup>
<ProjectReference Include="..\Project.Web\Project.Web.csproj">
<Name>Project.Web</Name>
<Project>{5d000123-0000-4b6e-b5fa-72525afca7f5}</Project>
<Private>True</Private>
<RoleType>Web</RoleType>
<RoleName>Project.Web</RoleName>
<UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>
<ProjectReference Include="..\ProjectWorker\ProjectWorker.csproj">
<Name>ProjectWorker</Name>
<Project>{22e99999-1000-4559-8507-a948b7e3d1b0}</Project>
<Private>True</Private>
<RoleType>Worker</RoleType>
<RoleName>ProjectWorker</RoleName>
<UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>
</ItemGroup>
Only two projects are referenced in the ccproj instead of 3.
The cloud project has 3 dependencies in the sln.
If I had a reference by hand in the ccproj like this:
<ProjectReference Include="..\Project.WebAPI\Project.WebAPI.csproj">
<Name>Project.Web</Name>
<Project>{A0F88888-3333-4823-A34F-5F01F0A3FFFF}</Project>
<Private>True</Private>
<RoleType>Web</RoleType>
<RoleName>Project.WebAPI</RoleName>
<UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>
I have this error:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0
\Microsoft.WindowsAzure.targets(987,5): error : CloudServices25 : Multiple directories are
specified for role Project.Web. [C:\CI\project\WindowsAzure\WindowsAzure.ccproj]
Now if I update the reference like this:
<ProjectReference Include="..\Project.WebAPI\Project.WebAPI.csproj">
<Name>Project.WebAPI</Name>
<Project>{A0F88888-3333-4823-A34F-5F01F0A3FFFF}</Project>
<Private>True</Private>
<RoleType>Web</RoleType>
<RoleName>Project.Web</RoleName>
<UpdateDiagnosticsConnectionStringOnPublish>True</UpdateDiagnosticsConnectionStringOnPublish>
</ProjectReference>
I have this error:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v11.0\Windows Azure Tools\2.0
\Microsoft.WindowsAzure.targets(987,5): error : CloudServices26 : Cannot find role
named 'Project.WebAPI' in service description file
C:\CI\project\WindowsAzure\bin\UAT\ServiceDefinition.csdef.
[C:\CI\project\WindowsAzure\WindowsAzure.ccproj]
I found this link: Visual Studio 2010 Beta 2 myTODO Error message it works for me. The valuable information from that link:
It seems like maybe Azure does not like it if you specify anything besides an Azure Role project as a dependency on the service project. I made it so MyWebRole.csproj was dependent on xxx.csproj, instead of MyService.ccproj being dependent on xxx.csproj, and it worked.
This post solved my problem:
http://michaelcollier.wordpress.com/2013/01/14/multiple-sites-in-a-web-role/
A must read if you have several websites on one webrole!
I stumbled upon a similar problem when building my cloud project from the command line, in particular I get this exception if the web project referenced by the VirtualDirectory tag is marked as a build dependency for the cloud project.
To avoid this and ensure that the web project is compiled and included in the cspack, I come up with a procedure simpler that the one cited in Swell's answer -- in particular it does not require to alter the project files but only to call two targets in a precise order:
ensure in Configuration Manager that the web project will be rebuilt in the desired solution configuration (for example ensure that it is built under Release configuration);
ensure that the web project is not a build dependency of the cloud project;
do a rebuild of the solution, for example
MsBuild solution.sln /t:Rebuild ...
This way the web project will be recompiled.
perform a publish of the cloud project, for example
MsBuild solution.sln /t:cloudproject.ccproj:publish ...
The web project will be copied correctly to the cspack file.

Categories

Resources