1
votes

I have a Cloud Service project that I use to deploy my WebRole through VSTS, on a Hosted Agent.

The build definition is created with the Azure Cloud Services template, and has, amongst others, these steps:

  • Build solution **\*.sln (step #1)
  • Build solution **\*.ccproj (step #2)

I've added

<AllowUnsafeBlocks>true</AllowUnsafeBlocks>

To the .csproj file of the class library that uses unsafe code (for the release and debug configurations). I am using the release configuration when deploying.

The Build solution **\*.sln step passes, but the Build solution **\*.ccproj step fails.

By inspecting the logs, I can see that the Build solution **\*.sln step is started with the /unsafe+ parameter, however the second build step is not.

Moreover, the MSBuild arguments for step #1 are empty, but for step #2, they are:

/t:Publish /p:TargetProfile=$(targetProfile) /p:DebugType=None /p:SkipInvalidConfigurations=true /p:OutputPath=bin\ /p:PublishDir="$(build.artifactstagingdirectory)\"

How can I add this parameter to the ccproj build?

2
It's better to post the solution as answer instead of add it to the question. Thus, forum readers may recognize questions and answers easily.starian chen-MSFT

2 Answers

1
votes

The <AllowUnsafeBlocks>true</AllowUnsafeBlocks> was added to the Release|AnyCPU condition:

  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>pdbonly</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\</OutputPath>
    <DefineConstants>TRACE</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
  </PropertyGroup>

However, when building the project with "any cpu" platform (which is default, with a space between 'any' and 'cpu') the condition does not get hit, contrary to when building a .sln project. I have to explicitly set the platform to "anycpu" without a space, and everything works. It wasnt opmitizing the code either, because of this.

enter image description here

0
votes

It uses default platform of your project (Open project file through NotePad, and check it) if removing Platform argument in VS build task, so you can check the value of BuildPlatform build variable (Variables tab) in build definition.