0
Hello, I have a project in C# windows Forms and I need to compile and generate the .exe
with Msbuild. However, when I update the sources and run to compile, it gives error saying that the structure of the code is wrong: with dot and comma missing, etc.
But if I get into the same project, compile from the Visual Studio IDE, and then go do it from Msbuild, it works smoothly. In my case I need to compile where the IDE is not installed.
Thank you very much.
Build error message with MSBUILD :
"D:\CRIS\Programas_Cris\Projeto\Projeto.sln" (destino padrão) (1) ->"D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj" (destino padrão) (2) ->
(CoreCompile destino) -> FrmPrincipal.cs(117,54): error CS1525: Termo de expressão inválido 'int' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(117,65): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(117,65): error CS1525: Termo de expressão inválido ',' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(117,67): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(117,68): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(117,68): error CS1525: Termo de expressão inválido ')' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(2028,55): error CS1525: Termo de expressão inválido 'int' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(2028,61): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(2028,61): error CS1525: Termo de expressão inválido ')' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(2028,62): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(2028,62): error CS1525: Termo de expressão inválido ')' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(2028,63): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(2032,13): error CS1525: Termo de expressão inválido 'else' [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
FrmPrincipal.cs(2032,17): error CS1002: ; esperado [D:\CRIS\Programas_Cris\Projeto\Projeto\Projeto.csproj]
Here the file . Csproj
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{2E1B2020-4F0A-4F82-90E0-A08B8D3E0E2F}</ProjectGuid>
<OutputType>WinExe</OutputType>
<RootNamespace>Projeto</RootNamespace>
<AssemblyName>Projeto</AssemblyName>
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Icone.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="DotNetZip, Version=1.13.8.0, Culture=neutral, PublicKeyToken=6583c7c814667745, processorArchitecture=MSIL">
<HintPath>..\packages\DotNetZip.1.13.8\lib\net40\DotNetZip.dll</HintPath>
</Reference>
<Reference Include="System">
<HintPath>..\..\..\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.dll</HintPath>
</Reference>
<Reference Include="System.Core" />
<Reference Include="System.ServiceProcess" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Deployment" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="Classes\Funcoes.cs" />
<Compile Include="FrmImagemPDV.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmImagemPDV.Designer.cs">
<DependentUpon>FrmImagemPDV.cs</DependentUpon>
</Compile>
<Compile Include="FrmPrincipal.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="FrmPrincipal.Designer.cs">
<DependentUpon>FrmPrincipal.cs</DependentUpon>
</Compile>
<Compile Include="Classes\INIFile.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<EmbeddedResource Include="FrmImagemPDV.resx">
<DependentUpon>FrmImagemPDV.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="FrmPrincipal.resx">
<DependentUpon>FrmPrincipal.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<SubType>Designer</SubType>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
</ItemGroup>
<ItemGroup>
<Content Include="Icone.ico" />
<None Include="Img\Lupa.png" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
Thank you very much for the answer, I put the file . csproj in question, I do not know if this wrong.
– Cristiano Rogoy
You need to compare the build parameters of Visual Studio with Msbuild.
– dalmo.santos
Got it, where do I find this Msbuild file ? if you can give me an example
– Cristiano Rogoy
Msbuild is a. net framework command used for compilation. For the compilation to be carried out successfully, you pass some parameters through commands or a file. I recommend reading: link
– dalmo.santos