score:3
Your type D visa allows you to be present in the other Schengen states besides the country of issue, provided that your stay in those countries does not exceed 90 days in any 180-day period. So yes, you can travel through France to get to Portugal from Switzerland during the validity period of that visa.
This was enacted by Regulation 265/2010, which amended the Schengen convention thus:
Aliens who hold valid residence permits issued by one of the Member States may, on the basis of that permit and a valid travel document, move freely for up to three months in any six-month period within the territories of the other Member States, provided that they fulfil the entry conditions referred to in Article 5(1)(a), (c) and (e) of Regulation (EC) No 562/2006 of the European Parliament and of the Council of 15 March 2006 establishing a Community Code on the rules governing the movement of persons across borders (Schengen Borders Code) ( 20 ) and are not on the national list of alerts of the Member State concerned.
and
The right of free movement laid down in paragraph 1 shall also apply to aliens who hold a valid long-stay visa issued by one of the Member States as provided for in Article 18.
Be careful, however: You say that the validity of your Swiss residence permit expires before you fly. If the Swiss residence permit expires before the Portuguese D visa becomes valid, then you will be without a valid visa or residence permit. In that case, unless your nationality allows you to stay in the Schengen area without a visa, you will need to leave the Schengen area between the expiration of your Swiss permit and the "valid from" date of your Portuguese visa.